]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONv1.cxx
Introduction of AliTRDLeastSquare
[u/mrichter/AliRoot.git] / MUON / AliMUONv1.cxx
index 702bc3b22d63e9eb6585bbab403a42069efdecfc..6ad827c500f75a09ceefd5752d1a832e4552a6eb 100644 (file)
 
 /* $Id$ */
 
-// --------------------
+//-----------------------------------------------------------------------------
 // Class AliMUONv1
 // --------------------
 // AliDetector class for MUON subsystem which implements
 // functions for simulation 
+//-----------------------------------------------------------------------------
 
 #include "AliMUONv1.h"
 #include "AliMUONConstants.h"
-#include "AliMUONSegFactory.h"
 #include "AliMUONResponseFactory.h"
-#include "AliMUONSegmentation.h"
 #include "AliMUONHit.h"
-#include "AliMUONTriggerCircuit.h"
-#include "AliMUONTriggerCircuitNew.h"
-#include "AliMUONTriggerCrateStore.h"
 #include "AliMUONGeometryBuilder.h"    
 #include "AliMUONGeometry.h"   
 #include "AliMUONGeometryTransformer.h"        
@@ -37,6 +33,9 @@
 #include "AliMUONStringIntMap.h"       
 #include "AliMUONGeometryDetElement.h" 
 
+#include "AliMpCDB.h"
+#include "AliMpDEManager.h"
+
 #include "AliConst.h" 
 #include "AliMagF.h"
 #include "AliRun.h"
 
 #include <string>
 
+#include "AliMUONVHitStore.h"
+
+/// \cond CLASSIMP
 ClassImp(AliMUONv1)
+/// \endcond
  
 //___________________________________________
 AliMUONv1::AliMUONv1() 
@@ -74,10 +77,8 @@ AliMUONv1::AliMUONv1()
 } 
 
 //___________________________________________
-AliMUONv1::AliMUONv1(const char *name, const char *title,
-                     const char* sDigitizerClassName,
-                     const char* digitizerClassName)
-: AliMUON(name,title,sDigitizerClassName,digitizerClassName), 
+AliMUONv1::AliMUONv1(const char *name, const char* title)
+: AliMUON(name, title), 
     fAngleEffect(kTRUE),
     fStepMaxInActiveGas(0.6),
     fStepSum(0x0),
@@ -92,6 +93,11 @@ AliMUONv1::AliMUONv1(const char *name, const char *title,
 
     AliDebug(1,Form("ctor this=%p",this));     
        
+    // Load mapping
+    if ( ! AliMpCDB::LoadMpSegmentation() ) {
+      AliFatal("Could not access mapping from OCDB !");
+    }
+       
     // By default include all stations
 
     fStepSum   = new Float_t [AliMUONConstants::NCh()];
@@ -122,15 +128,6 @@ AliMUONv1::AliMUONv1(const char *name, const char *title,
     fAngleEffectNorma->SetParameter(3,-1.490e-03);
 }
 
-//_____________________________________________________________________________
-AliMUONv1::AliMUONv1(const AliMUONv1& right) 
-  : AliMUON(right) 
-{  
-/// Copy constructor (not implemented)
-
-  AliFatal("Copy constructor not provided.");
-}
-
 //___________________________________________
 AliMUONv1::~AliMUONv1()
 {
@@ -144,19 +141,6 @@ AliMUONv1::~AliMUONv1()
   delete fAngleEffectNorma; 
 }
 
-//_____________________________________________________________________________
-AliMUONv1& AliMUONv1::operator=(const AliMUONv1& right)
-{
-/// Assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
-
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
-
 //__________________________________________________
 void AliMUONv1::CreateGeometry()
 {
@@ -173,6 +157,15 @@ void AliMUONv1::CreateMaterials()
   fGeometryBuilder->CreateMaterials();
 }
 
+//________________________________________________________________
+void AliMUONv1::AddAlignableVolumes() const
+{
+/// Construct materials using geometry builder
+
+  GetGeometryTransformer()->AddAlignableVolumes();
+}
+
+
 //___________________________________________
 void AliMUONv1::Init()
 { 
@@ -184,58 +177,29 @@ void AliMUONv1::Init()
   AliDebug(1,"Finished Init for version 1 - CPC chamber type");   
  
 
-  std::string ftype(GetTitle());
-
   // Build segmentation
   // using geometry parametrisation
   //
-  AliMUONSegFactory segFactory(GetGeometryTransformer());
-  fSegmentation = segFactory.CreateSegmentation(ftype);
-
-  if (!fSegmentation) {
-    AliFatal(Form("Wrong factory type : %s",ftype.c_str()));
-  }        
-
   // Build response
   //
-  AliMUONResponseFactory respFactory("default");
+  AliMUONResponseFactory respFactory("default", fIsTailEffect);
   respFactory.Build(this);
   
-
-  // Initialize segmentation
-  //
-  fSegmentation->Init();
-
-  // Initialize trigger circuits
-  //
-  for (Int_t i=0; i<AliMUONConstants::NTriggerCircuit(); i++)  {
-    AliMUONTriggerCircuit* c = (AliMUONTriggerCircuit*)(fTriggerCircuits->At(i));
-    c->Init(i);
-  }
-  
-  AliMUONTriggerCrateStore store;
-  store.ReadFromFile();
-  for (Int_t i=0; i<AliMUONConstants::NTriggerCircuit(); i++)  
-  {
-    AliMUONTriggerCircuitNew* c = (AliMUONTriggerCircuitNew*)(fTriggerCircuitsNew->At(i));
-    c->Init(i,store);
-  }
-  
 }
 
 //__________________________________________________________________
-Int_t  AliMUONv1::GetChamberId(Int_t volId) const
+Int_t  AliMUONv1::GetGeomModuleId(Int_t volId) const
 {
 /// Check if the volume with specified  volId is a sensitive volume (gas) 
-/// of some chamber and returns the chamber number;
+/// of some chamber and return the chamber number;
 /// if not sensitive volume - return 0.
 
-  for (Int_t i = 0; i < AliMUONConstants::NCh(); i++) {
+  for (Int_t i = 0; i < AliMUONConstants::NGeomModules(); i++) {
     if ( GetGeometry()->GetModule(i)->IsSensitiveVolume(volId) )
-      return i+1;
+      return i;
   }    
 
-  return 0;
+  return -1;
 }
 
 //_______________________________________________________________________________
@@ -274,8 +238,6 @@ void AliMUONv1::StepManager()
   // Only gas gap inside chamber
   // Tag chambers and record hits when track enters 
   static Int_t   idvol=-1, iEnter = 0;
-  Int_t   iChamber=0;
-  Int_t   id=0;
   Int_t   copy;
   const  Float_t kBig = 1.e10;
   static Double_t xyzEnter[3];
@@ -283,25 +245,31 @@ void AliMUONv1::StepManager()
   //
   // Only gas gap inside chamber
   // Tag chambers and record hits when track enters 
-  id=gMC->CurrentVolID(copy);
-  iChamber = GetChamberId(id);
-  idvol = iChamber -1;
+  Int_t id=gMC->CurrentVolID(copy);
+  Int_t iGeomModule = GetGeomModuleId(id);
+  if (iGeomModule == -1) return;
 
-  if (idvol == -1) return;
-  
   // Detection elements id
   const AliMUONGeometryModule* kGeometryModule
-    = GetGeometry()->GetModule(iChamber-1);
-
+    = GetGeometry()->GetModule(iGeomModule);
   AliMUONGeometryDetElement* detElement
     = kGeometryModule->FindBySensitiveVolume(CurrentVolumePath());
+    
+  if (!detElement && iGeomModule < AliMUONConstants::NGeomModules()-2) {
+    iGeomModule++;
+    const AliMUONGeometryModule* kGeometryModule2
+      = GetGeometry()->GetModule(iGeomModule);
+    detElement 
+      = kGeometryModule2->FindBySensitiveVolume(CurrentVolumePath());
+  }    
 
   Int_t detElemId = 0;
   if (detElement) detElemId = detElement->GetUniqueID(); 
  
   if (!detElemId) {
-    cerr << "Chamber id: "
-        << setw(3) << iChamber << "  "
+    AliErrorStream() 
+         << "Geometry module id: "
+        << setw(3) << iGeomModule << "  "
         << "Current SV: " 
         <<  CurrentVolumePath() 
          << "  detElemId: "
@@ -309,16 +277,20 @@ void AliMUONv1::StepManager()
          << endl;
     Double_t x, y, z;
     gMC->TrackPosition(x, y, z);        
-    cerr << "  global position: "
+    AliErrorStream() 
+         << "  global position: "
         << x << ", " << y << ", " << z
         << endl;
-    AliError("DetElemId not identified.");
-  }  
+    AliErrorStream() << "DetElemId not identified." << endl;
+  } 
+  
+  Int_t iChamber = AliMpDEManager::GetChamberId(detElemId) + 1; 
+  idvol = iChamber -1;
     
   // Filling TrackRefs file for MUON. Our Track references are the active volume of the chambers
   if ( (gMC->IsTrackEntering() || gMC->IsTrackExiting() ) ) {
     AliTrackReference* trackReference    
-      = AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+      = AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kMUON);
     trackReference->SetUserId(detElemId);
   }  
   
@@ -437,8 +409,7 @@ void AliMUONv1::StepManager()
     }
     }
     
-    // One hit per chamber
-    GetMUONData()->AddHit2(fIshunt, 
+    AliMUONHit hit(fIshunt, 
                          gAlice->GetMCApp()->GetCurrentTrackNumber(), 
                          detElemId, ipart,
                          fTrackPosition.X(), 
@@ -454,9 +425,7 @@ void AliMUONv1::StepManager()
                          fTrackPosition.Y(),
                          fTrackPosition.Z());
 
-    //       AliDebug(1,Form("Exit: Particle exiting from chamber %d",iChamber));
-    //       AliDebug(1,Form("Exit: StepSum %f eloss geant %g ",fStepSum[idvol],fDestepSum[idvol]));
-    //       AliDebug(1,Form("Exit: Track Position %f %f %f",fTrackPosition.X(),fTrackPosition.Y(),fTrackPosition.Z()) ;
+    fHitStore->Add(hit);
 
     fStepSum[idvol]  =0; // Reset for the next event
     fDestepSum[idvol]=0; // Reset for the next event