]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONv1.cxx
- Adding check and flagging for HG present
[u/mrichter/AliRoot.git] / MUON / AliMUONv1.cxx
index 078893a844c993a58f67ece02e7a7621f3f6f2ba..1718b69fc85919ea8347d59e88e48a120678173b 100644 (file)
@@ -33,6 +33,7 @@
 #include "AliMUONStringIntMap.h"       
 #include "AliMUONGeometryDetElement.h" 
 
+#include "AliMpCDB.h"
 #include "AliMpDEManager.h"
 
 #include "AliConst.h" 
 #include "AliTrackReference.h"
 #include "AliLog.h"
 
-#include <TRandom.h>
-#include <TF1.h>
 #include <TClonesArray.h>
+#include <TF1.h>
+#include <TF2.h>
+#include <TGeoGlobalMagField.h>
+#include <TGeoMatrix.h>
+#include <TRandom.h>
 #include <TRandom.h> 
 #include <TVirtualMC.h>
-#include <TGeoMatrix.h>
 
 #include <string>
 
@@ -61,6 +64,7 @@ ClassImp(AliMUONv1)
 AliMUONv1::AliMUONv1() 
   : AliMUON(),
     fAngleEffect(kTRUE),
+    fMagEffect(kTRUE),
     fStepMaxInActiveGas(0.6),
     fStepSum(0x0),
     fDestepSum(0x0),
@@ -68,7 +72,8 @@ AliMUONv1::AliMUONv1()
     fTrackPosition(),
     fElossRatio(0x0),
     fAngleEffect10(0x0),
-    fAngleEffectNorma(0x0)
+    fAngleEffectNorma(0x0),
+    fMagAngleEffectNorma(0x0)
 {
 /// Default constructor
   
@@ -79,6 +84,7 @@ AliMUONv1::AliMUONv1()
 AliMUONv1::AliMUONv1(const char *name, const char* title)
 : AliMUON(name, title), 
     fAngleEffect(kTRUE),
+    fMagEffect(kTRUE),
     fStepMaxInActiveGas(0.6),
     fStepSum(0x0),
     fDestepSum(0x0),
@@ -86,12 +92,18 @@ AliMUONv1::AliMUONv1(const char *name, const char* title)
     fTrackPosition(),
     fElossRatio(0x0),
     fAngleEffect10(0x0),
-    fAngleEffectNorma(0x0)
+    fAngleEffectNorma(0x0),
+    fMagAngleEffectNorma(0x0)
 {
 /// Standard onstructor
 
     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()];
@@ -120,6 +132,11 @@ AliMUONv1::AliMUONv1(const char *name, const char* title)
     fAngleEffectNorma->SetParameter(1,-6.809e-01);
     fAngleEffectNorma->SetParameter(2,5.151e-02);
     fAngleEffectNorma->SetParameter(3,-1.490e-03);
+
+    // Magnetic field effect: Normalisation form theta=16 degres (eq. 10 degrees B=0) to theta between -20 and 20 (Lamia Benhabib jun 2006 )  
+    // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
+    fMagAngleEffectNorma = new TF2("MagAngleEffectNorma","121.24/(([1]+[2]*abs(y))+[3]*abs(x-[0]*y)+[4]*abs((x-[0]*y)*(x-[0]*y))+[5]*abs((x-[0]*y)*(x-[0]*y)*(x-[0]*y))+[6]*abs((x-[0]*y)*(x-[0]*y)*(x-[0]*y)*(x-[0]*y)))",-20.0,20.0,-1.,1.);
+    fMagAngleEffectNorma->SetParameters(8.6995, 25.4022, 13.8822, 2.4717, 1.1551, -0.0624, 0.0012);
 }
 
 //___________________________________________
@@ -133,6 +150,7 @@ AliMUONv1::~AliMUONv1()
   delete fElossRatio;
   delete fAngleEffect10;
   delete fAngleEffectNorma; 
+  delete fMagAngleEffectNorma;
 }
 
 //__________________________________________________
@@ -151,6 +169,19 @@ void AliMUONv1::CreateMaterials()
   fGeometryBuilder->CreateMaterials();
 }
 
+//________________________________________________________________
+void AliMUONv1::UpdateInternalGeometry()
+{
+/// Update geometry after applying mis-alignment
+
+  // Load mapping
+  if ( ! AliMpCDB::LoadMpSegmentation() ) {
+    AliFatal("Could not access mapping from OCDB !");
+  }
+
+  fGeometryBuilder->UpdateInternalGeometry();
+}
+
 //________________________________________________________________
 void AliMUONv1::AddAlignableVolumes() const
 {
@@ -176,7 +207,7 @@ void AliMUONv1::Init()
   //
   // Build response
   //
-  AliMUONResponseFactory respFactory("default");
+  AliMUONResponseFactory respFactory("default", fIsTailEffect);
   respFactory.Build(this);
   
 }
@@ -290,7 +321,9 @@ void AliMUONv1::StepManager()
   
   if( gMC->IsTrackEntering() ) {
      Float_t theta = fTrackMomentum.Theta();
-     if ((TMath::Pi()-theta)*kRaddeg>=15.) gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
+     if ( fIsMaxStep && (TMath::Pi()-theta)*kRaddeg>=15. ) {
+       gMC->SetMaxStep(fStepMaxInActiveGas); // We use Pi-theta because z is negative
+     }  
      iEnter = 1;
      gMC->TrackPosition(xyzEnter[0], xyzEnter[1], xyzEnter[2]); // save coordinates of entrance point
   }
@@ -324,9 +357,10 @@ void AliMUONv1::StepManager()
        gMC->IsTrackDisappeared()||
        (fStepSum[idvol]>fStepMaxInActiveGas) ) {
     
-    if   ( gMC->IsTrackExiting() || 
-           gMC->IsTrackStop() || 
-           gMC->IsTrackDisappeared() ) gMC->SetMaxStep(kBig);
+    if   ( fIsMaxStep && 
+           ( gMC->IsTrackExiting() || 
+             gMC->IsTrackStop() || 
+             gMC->IsTrackDisappeared() ) ) gMC->SetMaxStep(kBig);
     if (fDestepSum[idvol] == 0) {
       // AZ - no energy release
       fStepSum[idvol] = 0; // Reset for the next event
@@ -386,10 +420,13 @@ void AliMUONv1::StepManager()
     Float_t sigmaEffectThetadegrees;
     Float_t eLossParticleELossMip;
     Float_t yAngleEffect=0.;
-    Float_t thetawires      =  TMath::Abs( TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) );// We use Pi-theta because z is negative
-
+    Float_t thetawires      =  TMath::ASin( TMath::Sin(TMath::Pi()-theta) * TMath::Sin(phi) ) ;// We use Pi-theta because z is negative
+    Double_t bField[3] = {0};
+    fTrackPosition.Vect().GetXYZ(tmp);
+    TGeoGlobalMagField::Instance()->Field(tmp,bField);
 
-    if (fAngleEffect){
+    if (fAngleEffect && !fMagEffect){
+      thetawires = TMath::Abs(thetawires);
     if ( (betaxGamma >3.2)   &&  (thetawires*kRaddeg<=15.) ) {
       betaxGamma=TMath::Log(betaxGamma);
       eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
@@ -402,23 +439,36 @@ void AliMUONv1::StepManager()
       yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
     }
     }
-    
-    AliMUONHit hit(fIshunt, 
-                         gAlice->GetMCApp()->GetCurrentTrackNumber(), 
-                         detElemId, ipart,
-                         fTrackPosition.X(), 
-                         fTrackPosition.Y()+yAngleEffect, 
-                         fTrackPosition.Z(), 
-                         gMC->TrackTime(),
-                         fTrackMomentum.P(),
-                         theta, 
-                         phi, 
-                         fStepSum[idvol], 
-                         fDestepSum[idvol],                        
-                         fTrackPosition.X(),
-                         fTrackPosition.Y(),
-                         fTrackPosition.Z());
+    else if (fAngleEffect && fMagEffect) {
+      if ( (betaxGamma >3.2)   &&  (TMath::Abs(thetawires*kRaddeg)<=15.) ) {
+       betaxGamma=TMath::Log(betaxGamma);
+       eLossParticleELossMip = fElossRatio->Eval(betaxGamma);
+       // 10 degrees is a reference for a model (arbitrary)
+       sigmaEffect10degrees=fAngleEffect10->Eval(eLossParticleELossMip);// in micrometers
+       // Angle with respect to the wires assuming that chambers are perpendicular to the z axis.
+       sigmaEffectThetadegrees =  sigmaEffect10degrees/fMagAngleEffectNorma->Eval(thetawires*kRaddeg,bField[0]/10.);  // For 5mm gap  
+      if ( (iChamber==1)  ||  (iChamber==2) )  
+        sigmaEffectThetadegrees/=(1.09833e+00+1.70000e-02*(thetawires*kRaddeg)); // The gap is different (4mm)
+       yAngleEffect=1.e-04*gRandom->Gaus(0,sigmaEffectThetadegrees); // Error due to the angle effect in cm
+      }
+    }
 
+    AliMUONHit hit(fIshunt, 
+                  gAlice->GetMCApp()->GetCurrentTrackNumber(), 
+                  detElemId, ipart,
+                  fTrackPosition.X(), 
+                  fTrackPosition.Y()+yAngleEffect, 
+                  fTrackPosition.Z(), 
+                  gMC->TrackTime(),
+                  fTrackMomentum.P(),
+                  theta, 
+                  phi, 
+                  fStepSum[idvol], 
+                  fDestepSum[idvol],                        
+                  fTrackPosition.X(),
+                  fTrackPosition.Y(),
+                  fTrackPosition.Z());
+    
     fHitStore->Add(hit);
 
     fStepSum[idvol]  =0; // Reset for the next event