]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDv1.cxx
MakeImage is now a method of AliCheckerBase, was AliQADataMaker before. This will...
[u/mrichter/AliRoot.git] / FMD / AliFMDv1.cxx
index 5c29d9e7eacae821532cdaa16f43eb1e3029c5e7..edff2cd49ae714ac43f7775f3a3115f3209e0487 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 /* $Id$ */
-
+/** @file    AliFMDv1.cxx
+    @author  Christian Holm Christensen <cholm@nbi.dk>
+    @date    Mon Mar 27 12:48:51 2006
+    @brief   Concrete implementation of FMD detector driver - detailed
+    version 
+    @ingroup FMD_sim
+*/
 //____________________________________________________________________
 //                                                                          
 // Forward Multiplicity Detector based on Silicon wafers. This class
 // contains the base procedures for the Forward Multiplicity detector
 // Detector consists of 3 sub-detectors FMD1, FMD2, and FMD3, each of
 // which has 1 or 2 rings of silicon sensors. 
-//                                                       
 // This class contains the detailed version of the FMD - that is, hits
 // are produced during simulation. 
 //                                                                           
 #include <TVirtualMC.h>                // ROOT_TVirtualMC
 #include <AliRun.h>            // ALIRUN_H
 #include <AliMC.h>             // ALIMC_H
-#include <AliLog.h>            // ALILOG_H
+// #include <AliLog.h>         // ALILOG_H
+#include "AliFMDDebug.h" // Better debug macros
 #include "AliFMDv1.h"          // ALIFMDV1_H
-#ifndef USE_PRE_MOVE
-#include "AliFMDGeometryBuilder.h"
+// #include "AliFMDGeometryBuilder.h"
 #include "AliFMDGeometry.h"
 #include "AliFMDDetector.h"
 #include "AliFMDRing.h"
 #include <TParticlePDG.h>
 #include <TDatabasePDG.h>
 #include "AliFMDHit.h"
-#else
-#include "AliFMDSimulator.h"   // ALIFMDSIMULATOR_H
-#include "AliFMDG3Simulator.h" // ALIFMDG3SIMULATOR_H
-#include "AliFMDGeoSimulator.h"        // ALIFMDGEOSIMULATOR_H
-#include "AliFMDG3OldSimulator.h"      // ALIFMDG3OLDSIMULATOR_H
-#include "AliFMDGeoOldSimulator.h"     // ALIFMDGEOOLDSIMULATOR_H
-#endif
 
 //____________________________________________________________________
 ClassImp(AliFMDv1)
@@ -56,13 +53,13 @@ ClassImp(AliFMDv1)
 #endif
 
 
-#ifndef USE_PRE_MOVE
 //____________________________________________________________________
 Bool_t
 AliFMDv1::VMC2FMD(TLorentzVector& v, UShort_t& detector,
                  Char_t& ring, UShort_t& sector, UShort_t& strip) const
 {
-  TVirtualMC* mc = TVirtualMC::GetMC();
+  // Convert VMC coordinates to detector coordinates 
+  TVirtualMC*      mc  = TVirtualMC::GetMC();
   AliFMDGeometry*  fmd = AliFMDGeometry::Instance();
 
   // Get track position
@@ -95,7 +92,7 @@ AliFMDv1::VMC2FMD(TLorentzVector& v, UShort_t& detector,
   if (t < 0 || t > 2 * theta) return kFALSE;
   else if (t > theta)         sector += 1;
 
-  AliDebug(40, Form("<1> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
+  AliFMDDebug(40, ("<1> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
                    detector, ring, sector, strip, mc->CurrentVolPath()));
   return kTRUE;
 }
@@ -106,7 +103,8 @@ AliFMDv1::VMC2FMD(Int_t copy, TLorentzVector& v,
                  UShort_t& detector, Char_t& ring,
                  UShort_t& sector, UShort_t& strip) const
 {
-  TVirtualMC* mc = TVirtualMC::GetMC();
+  // Convert VMC coordinates to detector coordinates 
+  TVirtualMC*     mc  = TVirtualMC::GetMC();
   AliFMDGeometry* fmd = AliFMDGeometry::Instance();
 
   strip = copy - 1;
@@ -117,6 +115,9 @@ AliFMDv1::VMC2FMD(Int_t copy, TLorentzVector& v,
   }
   else 
     sector = sectordiv;
+  AliFMDDebug(30, ("Getting ring volume with offset %d -> %s", 
+                   fmd->GetRingOff(), 
+                   mc->CurrentVolOffName(fmd->GetRingOff())));
   Int_t iring;     mc->CurrentVolOffID(fmd->GetRingOff(), iring); 
   ring = Char_t(iring);
   Int_t det;       mc->CurrentVolOffID(fmd->GetDetectorOff(), det); 
@@ -125,13 +126,17 @@ AliFMDv1::VMC2FMD(Int_t copy, TLorentzVector& v,
   //Double_t  rz  = fmd->GetDetector(detector)->GetRingZ(ring);
   AliFMDDetector* gdet  = fmd->GetDetector(detector);
   AliFMDRing*     gring = gdet->GetRing(ring);
-  if (!gring)
-    AliFatal(Form("Ring %c not found (%s)", ring, mc->CurrentVolPath()));
-  Int_t           n     = gring->GetNSectors();
+  if (!gring) {
+    AliFatal(Form("Ring %c not found (volume was %s at offset %d in path %s)", 
+                 ring, fmd->GetRingOff(), 
+                 mc->CurrentVolOffName(fmd->GetRingOff()),
+                 mc->CurrentVolPath()));
+  }
+  Int_t n = gring->GetNSectors();
 #if 0
   if (rz < 0) {
     Int_t s = ((n - sector + n / 2) % n) + 1;
-    AliDebug(1, Form("Recalculating sector to %d (=%d-%d+%d/2%%%d+1 z=%f)",
+    AliFMDDebug(1, ("Recalculating sector to %d (=%d-%d+%d/2%%%d+1 z=%f)",
                     s, n, sector, n, n, rz));
     sector = s;
   }
@@ -143,12 +148,64 @@ AliFMDv1::VMC2FMD(Int_t copy, TLorentzVector& v,
   sector--;
   // Get track position
   mc->TrackPosition(v);
-  AliDebug(15, Form("<2> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
+  AliFMDDebug(40, ("<2> Inside an active FMD volume FMD%d%c[%2d,%3d] %s",
                    detector, ring, sector, strip, mc->CurrentVolPath()));
 
   return kTRUE;
 }
-#endif
+
+
+//____________________________________________________________________
+Bool_t
+AliFMDv1::CheckHit(Int_t trackno, Int_t pdg, Float_t absQ, 
+                  const TLorentzVector& p, Float_t edep) const
+{
+  // Check that a hit is good 
+  if (AliLog::GetDebugLevel("FMD", "AliFMD") < 5) return kFALSE;
+  TVirtualMC* mc   = TVirtualMC::GetMC();
+  Double_t mass    = mc->TrackMass();
+  Double_t poverm  = (mass == 0 ? 0 : p.P() / mass);
+    
+  // This `if' is to debug abnormal energy depositions.  We trigger on
+  // p/m approx larger than or equal to a MIP, and a large edep - more 
+  // than 1 keV - a MIP is 100 eV. 
+  if (!(edep > absQ * absQ && poverm > 1)) return kFALSE;
+  
+  TArrayI procs;
+  mc->StepProcesses(procs);
+  TString processes;
+  for (Int_t ip = 0; ip < procs.fN; ip++) {
+    if (ip != 0) processes.Append(",");
+    processes.Append(TMCProcessName[procs.fArray[ip]]);
+  }
+  TDatabasePDG* pdgDB        = TDatabasePDG::Instance();
+  TParticlePDG* particleType = pdgDB->GetParticle(pdg);
+  TString pname(particleType ? particleType->GetName() : "???");
+  TString what;
+  if (mc->IsTrackEntering())    what.Append("entering ");
+  if (mc->IsTrackExiting())     what.Append("exiting ");
+  if (mc->IsTrackInside())      what.Append("inside ");
+  if (mc->IsTrackDisappeared()) what.Append("disappeared ");
+  if (mc->IsTrackStop())        what.Append("stopped ");
+  if (mc->IsNewTrack())         what.Append("new ");
+  if (mc->IsTrackAlive())       what.Append("alive ");
+  if (mc->IsTrackOut())         what.Append("out ");
+      
+  Int_t mother = gAlice->GetMCApp()->GetPrimary(trackno);
+  AliFMDDebug(15, ("Track # %5d deposits a lot of energy\n" 
+                   "  Volume:    %s\n" 
+                   "  Momentum:  (%7.4f,%7.4f,%7.4f)\n"
+                   "  PDG:       %d (%s)\n" 
+                   "  Edep:      %-14.7f keV (mother %d)\n"
+                   "  p/m:       %-7.4f/%-7.4f = %-14.7f\n"
+                   "  Processes: %s\n"
+                   "  What:      %s\n",
+                   trackno, mc->CurrentVolPath(), p.X(), p.Y(), p.Z(),
+                   pdg, pname.Data(), edep, mother, p.P(), mass, 
+                   poverm, processes.Data(), what.Data()));
+  return kTRUE;
+}
+
 
 //____________________________________________________________________
 void 
@@ -184,7 +241,6 @@ AliFMDv1::StepManager()
   //   -   Create a hit 
   //   - ENDIF
   //     
-#ifndef USE_PRE_MOVE
   TVirtualMC* mc = TVirtualMC::GetMC();
   if (!mc->IsTrackAlive()) return;
   Double_t absQ = TMath::Abs(mc->TrackCharge());
@@ -194,7 +250,7 @@ AliFMDv1::StepManager()
   Int_t vol = mc->CurrentVolID(copy);
   AliFMDGeometry*  fmd = AliFMDGeometry::Instance();
   if (!fmd->IsActive(vol)) {
-    AliDebug(50, Form("Not an FMD volume %d '%s'",vol,mc->CurrentVolName()));
+    AliFMDDebug(50, ("Not an FMD volume %d '%s'",vol,mc->CurrentVolName()));
     return;
   }
   TLorentzVector v;
@@ -212,49 +268,8 @@ AliFMDv1::StepManager()
   mc->TrackMomentum(p);
   Int_t    trackno = gAlice->GetMCApp()->GetCurrentTrackNumber();
   Int_t    pdg     = mc->TrackPid();
-  Double_t mass    = mc->TrackMass();
   Double_t edep    = mc->Edep() * 1000; // keV
-  Double_t poverm  = (mass == 0 ? 0 : p.P() / mass);
-  Bool_t   isBad   = kFALSE;
-  
-  // This `if' is to debug abnormal energy depositions.  We trigger on
-  // p/m approx larger than or equal to a MIP, and a large edep - more 
-  // than 1 keV - a MIP is 100 eV. 
-  if (edep > absQ * absQ && poverm > 1) {
-    isBad = kTRUE;
-    TArrayI procs;
-    mc->StepProcesses(procs);
-    TString processes;
-    for (Int_t ip = 0; ip < procs.fN; ip++) {
-      if (ip != 0) processes.Append(",");
-      processes.Append(TMCProcessName[procs.fArray[ip]]);
-    }
-    TDatabasePDG* pdgDB        = TDatabasePDG::Instance();
-    TParticlePDG* particleType = pdgDB->GetParticle(pdg);
-    TString pname(particleType ? particleType->GetName() : "???");
-    TString what;
-    if (mc->IsTrackEntering())    what.Append("entering ");
-    if (mc->IsTrackExiting())     what.Append("exiting ");
-    if (mc->IsTrackInside())      what.Append("inside ");
-    if (mc->IsTrackDisappeared()) what.Append("disappeared ");
-    if (mc->IsTrackStop())        what.Append("stopped ");
-    if (mc->IsNewTrack())         what.Append("new ");
-    if (mc->IsTrackAlive())       what.Append("alive ");
-    if (mc->IsTrackOut())         what.Append("out ");
-    
-    Int_t mother = gAlice->GetMCApp()->GetPrimary(trackno);
-    AliWarning(Form("Track # %5d deposits a lot of energy\n" 
-                   "  Volume:    %s\n" 
-                   "  Momentum:  (%7.4f,%7.4f,%7.4f)\n"
-                   "  PDG:       %d (%s)\n" 
-                   "  Edep:      %-14.7f keV (mother %d)\n"
-                   "  p/m:       %-7.4f/%-7.4f = %-14.7f\n"
-                   "  Processes: %s\n"
-                   "  What:      %s\n",
-                   trackno, mc->CurrentVolPath(), p.X(), p.Y(), p.Z(),
-                   pdg, pname.Data(), edep, mother, p.P(), mass, 
-                   poverm, processes.Data(), what.Data()));
-  }
+  Bool_t   isBad   = CheckHit(trackno, pdg, absQ, p, edep);
   
   // Check that the track is actually within the active area 
   Bool_t entering = mc->IsTrackEntering();
@@ -264,7 +279,7 @@ AliFMDv1::StepManager()
   // Reset the energy deposition for this track, and update some of
   // our parameters.
   if (entering) {
-    AliDebug(15, Form("Track # %8d entering active FMD volume %s: "
+    AliFMDDebug(15, ("Track # %8d entering active FMD volume %s: "
                      "Edep=%f (%f,%f,%f)", trackno, mc->CurrentVolPath(),
                      edep, v.X(), v.Y(), v.Z()));
     fCurrentP      = p;
@@ -275,7 +290,7 @@ AliFMDv1::StepManager()
   // If the track is inside, then update the energy deposition
   if (inside && fCurrentDeltaE >= 0) {
     fCurrentDeltaE += edep;
-    AliDebug(15, Form("Track # %8d inside active FMD volume %s: Edep=%f, "
+    AliFMDDebug(15, ("Track # %8d inside active FMD volume %s: Edep=%f, "
                      "Accumulated Edep=%f  (%f,%f,%f)", trackno, 
                      mc->CurrentVolPath(), edep, fCurrentDeltaE, 
                      v.X(), v.Y(), v.Z()));
@@ -286,7 +301,7 @@ AliFMDv1::StepManager()
   if (out) {
     if (fCurrentDeltaE >= 0) {
       fCurrentDeltaE += edep;
-      AliDebug(15, Form("Track # %8d exiting active FMD volume %s: Edep=%g, "
+      AliFMDDebug(15, ("Track # %8d exiting active FMD volume %s: Edep=%g, "
                        "Accumulated Edep=%g (%f,%f,%f)", trackno, 
                        mc->CurrentVolPath(), edep, fCurrentDeltaE, 
                        v.X(), v.Y(), v.Z()));
@@ -303,20 +318,16 @@ AliFMDv1::StepManager()
       if (isBad && fBad) { 
        new ((*fBad)[fBad->GetEntries()]) AliFMDHit(*h);
       }
+      // Check the geometry that we can get back the coordinates. 
+#ifdef CHECK_TRANS
+      Double_t x, y, z;
+      fmd->Detector2XYZ(detector, ring, sector, strip, x, y ,z);
+      AliFMDDebug(1, ("Hit at (%f,%f,%f), geometry says (%f,%f,%f)", 
+                      fCurrentV.X(), fCurrentV.Y(), fCurrentV.Z(), x, y, z));
+#endif
     }
     fCurrentDeltaE = -1;
   }
-#else
-  // Called for every step in the Forward Multiplicity Detector
-  //
-  // The message is deligated to AliFMDSimulator::Exec 
-  // 
-  if (!fSimulator) {
-    AliFatal("No simulator object made");
-    return;
-  }
-  fSimulator->Exec("");
-#endif
 }
 //___________________________________________________________________
 //