]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMD.cxx
Last fixes before declaring (almost) success
[u/mrichter/AliRoot.git] / FMD / AliFMD.cxx
index c6a89586792e5f9e2863952223d780b661f368bb..7b598c23b1a83bef417404187a4157813a32096d 100644 (file)
 //       +----+--------------+                 +--| AliFMDDigitizer |
 //       |                                     |  +-----------------+
 //       |           +---------------------+   |
-//       |        +- | AliFMDBaseDigitizer |<--+
+//       |        +--| AliFMDBaseDigitizer |<--+
 //       V     1  |  +---------------------+   |
 //  +--------+<>--+                            |  +------------------+
 //  | AliFMD |                                 +--| AliFMDSDigitizer |    
 //  +--------+<>--+                               +------------------+       
-//            1  | +-----------------+ 
-//               +-| AliFMDSimulator |
-//                 +-----------------+
-//                           ^              
-//                           |
-//             +-------------+-------------+
-//             |                           |         
-//    +--------------------+   +-------------------+
-//    | AliFMDGeoSimulator |   | AliFMDG3Simulator | 
-//    +--------------------+   +---------+---------+
+//            1  |  +-----------------+ 
+//               +--| AliFMDSimulator |
+//                  +-----------------+
+//                            ^              
+//                            |
+//              +-------------+-------------+
+//              |                           |        
+//     +--------------------+   +-------------------+
+//     | AliFMDGeoSimulator |   | AliFMDG3Simulator | 
+//     +--------------------+   +-------------------+
+//               ^                        ^
+//               |                        |
+//  +-----------------------+   +----------------------+
+//  | AliFMDGeoOldSimulator |   | AliFMDG3OldSimulator |
+//  +-----------------------+   +----------------------+
 //      
 //
 // *  AliFMD 
 #include <TBrowser.h>          // ROOT_TBrowser
 #include <TMath.h>             // ROOT_TMath
 #include <TVirtualMC.h>                // ROOT_TVirtualMC
+#include <TVector2.h>
+#include <TVector3.h>
+#include <TMarker3DBox.h>
 
 #include <AliRunDigitizer.h>   // ALIRUNDIGITIZER_H
 #include <AliLoader.h>         // ALILOADER_H
 #include <AliRun.h>            // ALIRUN_H
 #include <AliMC.h>             // ALIMC_H
+#include "AliMagF.h"           // ALIMAGF_H
 #include <AliLog.h>            // ALILOG_H
 #include "AliFMD.h"            // ALIFMD_H
 #include "AliFMDDigit.h"       // ALIFMDDIGIG_H
 #include "AliFMDDetector.h"    // ALIFMDDETECTOR_H
 #include "AliFMDRing.h"                // ALIFMDRING_H
 #include "AliFMDDigitizer.h"   // ALIFMDDIGITIZER_H
-#include "AliFMDSimulator.h"   // ALIFMDSIMULATOR_H
-#include "AliFMDG3Simulator.h" // ALIFMDG3SIMULATOR_H
-#include "AliFMDGeoSimulator.h"        // ALIFMDGEOSIMULATOR_H
+#include "AliPoints.h"         // ALIPOINTS_H
+#include "AliFMDGeometryBuilder.h"
 #include "AliFMDRawWriter.h"   // ALIFMDRAWWRITER_H
 
+
+class AliFMDPoints : public AliPoints 
+{
+public:
+  AliFMDPoints(AliFMDHit* hit, UInt_t color) 
+    : AliPoints(1), fMarker(0)
+  {
+    if (!hit) return;
+    Float_t  size  = TMath::Min(TMath::Max(hit->Edep() * .1, .1), 1.);
+    TVector3 p(hit->Px(), hit->Py(), hit->Pz());
+    fMarker = new TMarker3DBox(hit->X(), hit->Y(), hit->Z(), size, size, size,
+                              p.Theta(), p.Phi());
+    fMarker->SetLineColor(color);
+    fMarker->SetRefObject(this);
+    fP[0] = hit->X();
+    fP[1] = hit->Y();
+    fP[2] = hit->Z();
+  }
+  ~AliFMDPoints() 
+  {
+    // if (fMarker) delete  fMarker;
+  }
+  void SetXYZ(Double_t x, Double_t y, Double_t z)
+  {
+    if (fMarker) fMarker->SetPosition(x, y, z);
+  }
+  Int_t DistancetoPrimitive(Int_t px, Int_t py) 
+  {
+    return fMarker->DistancetoPrimitive(px, py);
+  }
+  void Draw(Option_t* option) 
+  {
+    if (fMarker) fMarker->Draw(option);
+  }
+  void Paint(Option_t* option)
+  {
+    if (fMarker) fMarker->Paint(option);
+  }
+  void SetMarkerColor(Color_t colour) 
+  {
+    if (fMarker) fMarker->SetLineColor(colour);
+  }
+private:
+  TMarker3DBox* fMarker;
+};
+
+
 //____________________________________________________________________
 ClassImp(AliFMD)
 #if 0
@@ -123,18 +178,22 @@ ClassImp(AliFMD)
 
 //____________________________________________________________________
 AliFMD::AliFMD()
-  : fSDigits(0), 
+  : AliDetector(),
+    fSDigits(0), 
     fNsdigits(0),
     fDetailed(kTRUE),
-    fSimulator(0)
+    fBad(0)
 {
   //
   // Default constructor for class AliFMD
   //
   AliDebug(10, "\tDefault CTOR");
-  fHits     = 0;
-  fDigits   = 0;
-  fIshunt   = 0;
+  fHits        = 0;
+  fDigits      = 0;
+  fIshunt      = 0;
+  fUseOld      = kFALSE;
+  fUseAssembly = kTRUE;
+  fBad         = new TClonesArray("AliFMDHit");
 }
 
 //____________________________________________________________________
@@ -143,9 +202,11 @@ AliFMD::AliFMD(const AliFMD& other)
     fSDigits(other.fSDigits), 
     fNsdigits(other.fNsdigits),
     fDetailed(other.fDetailed),
-    fSimulator(other.fSimulator)
+    fBad(other.fBad)
 {
   // Copy constructor 
+  fUseOld      = other.fUseOld;
+  fUseAssembly = other.fUseAssembly;
 }
 
 //____________________________________________________________________
@@ -154,13 +215,16 @@ AliFMD::AliFMD(const char *name, const char *title)
     fSDigits(0),
     fNsdigits(0),
     fDetailed(kTRUE),
-    fSimulator(0)
+    fBad(0)
 {
   //
   // Standard constructor for Forward Multiplicity Detector
   //
   AliDebug(10, "\tStandard CTOR");
-
+  fUseOld      = kFALSE;
+  fUseAssembly = kFALSE;
+  fBad         = new TClonesArray("AliFMDHit");
+  
   // Initialise Hit array
   HitsArray();
   gAlice->GetMCApp()->AddHitList(fHits);
@@ -194,18 +258,23 @@ AliFMD::~AliFMD ()
     delete fSDigits;
     fSDigits = 0;
   }
+  if (fBad) {
+    fBad->Delete();
+    delete fBad;
+    fBad = 0;
+  }
 }
 
 //____________________________________________________________________
 AliFMD&
 AliFMD::operator=(const AliFMD& other)
 {
+  // Assignment operator
   AliDetector::operator=(other);
   fSDigits             = other.fSDigits; 
   fNsdigits            = other.fNsdigits;
   fDetailed            = other.fDetailed;
-  fSimulator            = other.fSimulator;
-  
+  fBad                  = other.fBad;
   return *this;
 }
 
@@ -242,60 +311,225 @@ AliFMD::CreateGeometry()
   //     AliFMDSubDetector::Geomtry();
   //   END FOR
   //
-  if (!fSimulator) {
-    AliFatal("Simulator object not made yet!");
-    return;
-  }
-  fSimulator->DefineGeometry();
+  AliFMDGeometry*  fmd = AliFMDGeometry::Instance();
+  fmd->SetDetailed(fDetailed);
+  fmd->UseAssembly(fUseAssembly);
+  fmd->Build();
 }    
 
 //____________________________________________________________________
 void AliFMD::CreateMaterials() 
 {
-  // Register various materials and tracking mediums with the
-  // backend.   
+  // Define the materials and tracking mediums needed by the FMD
+  // simulation.   These mediums are made by sending the messages
+  // AliMaterial, AliMixture, and AliMedium to the passed AliModule
+  // object module.   The defined mediums are 
   // 
+  //   FMD Si$         Silicon (active medium in sensors)
+  //   FMD C$          Carbon fibre (support cone for FMD3 and vacuum pipe)
+  //   FMD Al$         Aluminium (honeycomb support plates)
+  //   FMD PCB$        Printed Circuit Board (FEE board with VA1_3)
+  //   FMD Chip$       Electronics chips (currently not used)
+  //   FMD Air$        Air (Air in the FMD)
+  //   FMD Plastic$    Plastic (Support legs for the hybrid cards)
+  //
+  // Pointers to TGeoMedium objects are retrived from the TGeoManager
+  // singleton.  These pointers are later used when setting up the
+  // geometry 
   AliDebug(10, "\tCreating materials");
-
-  if (fSimulator) {
-    AliFatal("Simulator object already instantised!");
-    return;
-  }
+  // Get pointer to geometry singleton object. 
   AliFMDGeometry* geometry = AliFMDGeometry::Instance();
   geometry->Init();
-//   TVirtualMC* mc = TVirtualMC::GetMC();
-//   Bool_t geo = mc->IsRootGeometrySupported();
-//   if (geo)
-//     fSimulator = new AliFMDGeoSimulator(this, fDetailed);
-//   else 
-    fSimulator = new AliFMDG3Simulator(this, fDetailed);
+#if 0
+  if (gGeoManager && gGeoManager->GetMedium("FMD Si$")) {
+    // We need to figure out the some stuff about the geometry
+    fmd->ExtractGeomInfo();
+    return;
+  }
+#endif  
+  Int_t    id;
+  Double_t a                = 0;
+  Double_t z                = 0;
+  Double_t density          = 0;
+  Double_t radiationLength  = 0;
+  Double_t absorbtionLength = 999;
+  Int_t    fieldType        = gAlice->Field()->Integ();     // Field type 
+  Double_t maxField         = gAlice->Field()->Max();     // Field max.
+  Double_t maxBending       = 0;     // Max Angle
+  Double_t maxStepSize      = 0.001; // Max step size 
+  Double_t maxEnergyLoss    = 1;     // Max Delta E
+  Double_t precision        = 0.001; // Precision
+  Double_t minStepSize      = 0.001; // Minimum step size 
+  // Silicon 
+  a                = 28.0855;
+  z                = 14.;
+  density          = geometry->GetSiDensity();
+  radiationLength  = 9.36;
+  maxBending       = 1;
+  maxStepSize      = .001;
+  precision        = .001;
+  minStepSize      = .001;
+  id               = kSiId;
+  AliMaterial(id, "Si$", a, z, density, radiationLength, absorbtionLength);
+  AliMedium(kSiId, "Si$", id,1,fieldType,maxField,maxBending,
+           maxStepSize,maxEnergyLoss,precision,minStepSize);
   
-  fSimulator->DefineMaterials();
+
+  // Carbon 
+  a                = 12.011;
+  z                = 6.;
+  density          = 2.265;
+  radiationLength  = 18.8;
+  maxBending       = 10;
+  maxStepSize      = .01;
+  precision        = .003;
+  minStepSize      = .003;
+  id               = kCarbonId;
+  AliMaterial(id, "Carbon$", a, z, density, radiationLength, absorbtionLength);
+  AliMedium(kCarbonId, "Carbon$", id,0,fieldType,maxField,maxBending,
+                   maxStepSize,maxEnergyLoss,precision,minStepSize);
+
+  // Aluminum
+  a                = 26.981539;
+  z                = 13.;
+  density          = 2.7;
+  radiationLength  = 8.9;
+  id               = kAlId;
+  AliMaterial(id, "Aluminum$",a,z, density, radiationLength, absorbtionLength);
+  AliMedium(kAlId, "Aluminum$", id, 0, fieldType, maxField, maxBending,
+           maxStepSize, maxEnergyLoss, precision, minStepSize);
+  
+  
+  // Copper 
+  a                = 63.546;
+  z                = 29;
+  density          =  8.96;
+  radiationLength  =  1.43;
+  id               = kCopperId;
+  AliMaterial(id, "Copper$", 
+                     a, z, density, radiationLength, absorbtionLength);
+  AliMedium(kCopperId, "Copper$", id, 0, fieldType, maxField, maxBending,
+           maxStepSize, maxEnergyLoss, precision, minStepSize);
+  
+
+  // Silicon chip 
+  {
+    Float_t as[] = { 12.0107,      14.0067,      15.9994,
+                     1.00794,     28.0855,     107.8682 };
+    Float_t zs[] = {  6.,           7.,           8.,
+                     1.,          14.,          47. };
+    Float_t ws[] = {  0.039730642,  0.001396798,  0.01169634,
+                     0.004367771,  0.844665,     0.09814344903 };
+    density          = 2.36436;
+    maxBending       = 10;
+    maxStepSize      = .01;
+    precision        = .003;
+    minStepSize      = .003;
+    id               = kSiChipId;
+    AliMixture(id, "Si Chip$", as, zs, density, 6, ws);
+    AliMedium(kSiChipId, "Si Chip$",  id, 0, fieldType, maxField, maxBending, 
+             maxStepSize, maxEnergyLoss, precision, minStepSize);
+  }
+  
+  // Kaption
+  {
+    Float_t as[] = { 1.00794,  12.0107,  14.010,   15.9994};
+    Float_t zs[] = { 1.,        6.,       7.,       8.};
+    Float_t ws[] = { 0.026362,  0.69113,  0.07327,  0.209235};
+    density          = 1.42;
+    maxBending       = 1;
+    maxStepSize      = .001;
+    precision        = .001;
+    minStepSize      = .001;
+    id               = kKaptonId;
+    AliMixture(id, "Kaption$", as, zs, density, 4, ws);
+    AliMedium(kKaptonId, "Kaption$", id,0,fieldType,maxField,maxBending,
+             maxStepSize,maxEnergyLoss,precision,minStepSize);
+  }
+
+  // Air
+  {
+    Float_t as[] = { 12.0107, 14.0067,   15.9994,  39.948 };
+    Float_t zs[] = {  6.,      7.,       8.,       18. };
+    Float_t ws[] = { 0.000124, 0.755267, 0.231781, 0.012827 }; 
+    density      = .00120479;
+    maxBending   = 1;
+    maxStepSize  = .001;
+    precision    = .001;
+    minStepSize  = .001;
+    id           = kAirId;
+    AliMixture(id, "Air$", as, zs, density, 4, ws);
+    AliMedium(kAirId, "Air$", id,0,fieldType,maxField,maxBending,
+             maxStepSize,maxEnergyLoss,precision,minStepSize);
+  }
+  
+  // PCB
+  {
+    Float_t zs[] = { 14.,         20.,         13.,         12.,
+                     5.,         22.,         11.,         19.,
+                    26.,          9.,          8.,          6.,
+                     7.,          1.};
+    Float_t as[] = { 28.0855,     40.078,      26.981538,   24.305, 
+                    10.811,      47.867,      22.98977,    39.0983,
+                    55.845,      18.9984,     15.9994,     12.0107,
+                    14.0067,      1.00794};
+    Float_t ws[] = {  0.15144894,  0.08147477,  0.04128158,  0.00904554, 
+                     0.01397570,  0.00287685,  0.00445114,  0.00498089,
+                     0.00209828,  0.00420000,  0.36043788,  0.27529426,
+                     0.01415852,  0.03427566};
+    density      = 1.8;
+    maxBending   = 1;
+    maxStepSize  = .001;
+    precision    = .001;
+    minStepSize  = .001;
+    id           = kPcbId;
+    AliMixture(id, "PCB$", as, zs, density, 14, ws);
+    AliMedium(kPcbId, "PCB$", id,0,fieldType,maxField,maxBending,
+             maxStepSize,maxEnergyLoss,precision,minStepSize);
+  }
+  
+  // Plastic 
+  {
+    Float_t as[] = { 1.01, 12.01 };
+    Float_t zs[] = { 1.,   6.    };
+    Float_t ws[] = { 1.,   1.    };
+    density      = 1.03;
+    maxBending   = 10;
+    maxStepSize  = .01;
+    precision    = .003;
+    minStepSize  = .003;
+    id           = kPlasticId;
+    AliMixture(id, "Plastic$", as, zs, density, -2, ws);
+    AliMedium(kPlasticId, "Plastic$", id,0,fieldType,maxField,maxBending,
+             maxStepSize,maxEnergyLoss,precision,minStepSize);
+  }
 }
 
 //____________________________________________________________________
 void  
 AliFMD::Init()
 {
-  //
-  // Initialis the FMD after it has been built
-  Int_t i;
-  //
-  if (AliLog::GetGlobalDebugLevel()) {
-    cout << "\n" << ClassName() << ": " << flush;
-    for (i = 0; i < 35; i++) cout << "*";
-    cout << " FMD_INIT ";
-    for (i = 0; i < 35; i++) cout << "*";
-    cout << "\n" << ClassName() << ": " << flush;
-    //
-    // Here the FMD initialisation code (if any!)
-    for (i = 0; i < 80; i++) cout << "*";
-    cout << endl;
+  AliDebug(1, "Initialising FMD detector object");
+  // AliFMDGeometry*  fmd = AliFMDGeometry::Instance();
+  // fmd->InitTransformations();
+}
+
+//____________________________________________________________________
+void
+AliFMD::FinishEvent()
+{
+  if (AliLog::GetDebugLevel("FMD", "AliFMD") < 10) return;
+  if (fBad && fBad->GetEntries() > 0) {
+    AliWarning((Form("EndEvent", "got %d 'bad' hits", fBad->GetEntries())));
+    TIter next(fBad);
+    AliFMDHit* hit;
+    while ((hit = static_cast<AliFMDHit*>(next()))) hit->Print("D");
+    fBad->Clear();
   }
-  //
-  //
 }
 
+
 //====================================================================
 //
 // Graphics and event display
@@ -426,6 +660,79 @@ AliFMD::BuildGeometry()
   } // for (Int_t i = 1 ; ...)
 }
 
+//____________________________________________________________________
+void 
+AliFMD::LoadPoints(Int_t /* track */) 
+{
+  //
+  // Store x, y, z of all hits in memory
+  //
+  if (!fHits) {
+    AliError(Form("fHits == 0. Name is %s",GetName()));
+    return;
+  }
+  Int_t nHits = fHits->GetEntriesFast();
+  if (nHits == 0) {
+    return;
+  }
+  Int_t tracks = gAlice->GetMCApp()->GetNtrack();
+  if (fPoints == 0) fPoints = new TObjArray(2 * tracks);
+
+  // Get geometry 
+  AliFMDGeometry* geom = AliFMDGeometry::Instance();
+  geom->Init();
+  geom->InitTransformations();
+
+  // Now make markers for each hit  
+  // AliInfo(Form("Drawing %d hits (have %d points) for track %d", 
+  //              nHits, fPoints->GetEntriesFast(), track));
+  for (Int_t ihit = 0; ihit < nHits; ihit++) {
+    AliFMDHit* hit = static_cast<AliFMDHit*>(fHits->At(ihit));
+    if (!hit) continue;
+    Double_t edep    = hit->Edep();
+    Double_t m       = hit->M();
+    Double_t poverm  = (m == 0 ? 0 : hit->P());
+    Double_t absQ    = TMath::Abs(hit->Q());
+    Bool_t   bad     = 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) bad = kTRUE;
+
+    AliFMDPoints* p1 = new AliFMDPoints(hit, GetMarkerColor());
+    // AliPoints* p1 = new AliPoints();
+    // p1->SetMarkerColor(GetMarkerColor());
+    // p1->SetMarkerSize(GetMarkerSize());
+    // p1->SetPoint(0, hit->X(), hit->Y(), hit->Z());
+    p1->SetDetector(this);
+    p1->SetParticle(hit->GetTrack());
+    fPoints->AddAt(p1, hit->GetTrack());
+    if (bad) {
+      p1->SetMarkerColor(4);
+      // p1->SetMarkerSize(2 * GetMarkerSize());
+    }
+    
+    Double_t x, y, z;
+    geom->Detector2XYZ(hit->Detector(), hit->Ring(), hit->Sector(), 
+                      hit->Strip(), x, y, z);
+    AliFMDPoints* p = new AliFMDPoints(hit, 3);
+    // AliPoints* p = new AliPoints();
+    // p->SetMarkerColor(3);
+    // p->SetMarkerSize(GetMarkerSize());
+    // p->SetPoint(0, x, y, z);
+    p->SetDetector(this);
+    p->SetParticle(hit->GetTrack());
+    p->SetXYZ(x, y, z);
+    p->SetMarkerColor(3);
+    fPoints->AddAt(p, tracks+hit->GetTrack());
+    if (bad) {
+      p->SetMarkerColor(5);
+      // p->SetMarkerSize(2 * GetMarkerSize());
+    }
+    // AliInfo(Form("Adding point at %d", tracks+hit->GetTrack()));
+  }
+}
+
 //____________________________________________________________________
 void 
 AliFMD::DrawDetector()
@@ -575,7 +882,7 @@ AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
 }
 
 //____________________________________________________________________
-void 
+AliFMDHit*
 AliFMD::AddHitByFields(Int_t    track, 
                       UShort_t detector, 
                       Char_t   ring, 
@@ -589,7 +896,9 @@ AliFMD::AddHitByFields(Int_t    track,
                       Float_t  pz,
                       Float_t  edep,
                       Int_t    pdg,
-                      Float_t  t)
+                      Float_t  t, 
+                      Float_t  l, 
+                      Bool_t   stop)
 {
   //
   // Add a hit to the list
@@ -610,6 +919,8 @@ AliFMD::AddHitByFields(Int_t    track,
   //    edep     Energy deposited by track
   //    pdg      Track's particle Id #
   //    t        Time when the track hit 
+  //    l         Track length through the material. 
+  //    stop      Whether track was stopped or disappeared
   // 
   TClonesArray& a = *(HitsArray());
   // Search through the list of already registered hits, and see if we
@@ -617,26 +928,29 @@ AliFMD::AddHitByFields(Int_t    track,
   // a new hit, but rather update the energy deposited in the hit.
   // This is done, so that a FLUKA based simulation will get the
   // number of hits right, not just the enerrgy deposition. 
+  AliFMDHit* hit = 0;
   for (Int_t i = 0; i < fNhits; i++) {
     if (!a.At(i)) continue;
-    AliFMDHit* hit = static_cast<AliFMDHit*>(a.At(i));
+    hit = static_cast<AliFMDHit*>(a.At(i));
     if (hit->Detector() == detector 
        && hit->Ring() == ring
        && hit->Sector() == sector 
        && hit->Strip() == strip
        && hit->Track() == track) {
-      Warning("AddHit", "already had a hit in FMD%d%c[%2d,%3d] for track # %d,"
-             " adding energy (%f) to that hit (%f) -> %f", 
-             detector, ring, sector, strip, track, edep, hit->Edep(),
-             hit->Edep() + edep);
+      AliDebug(1, Form("already had a hit in FMD%d%c[%2d,%3d] for track # %d,"
+                      " adding energy (%f) to that hit (%f) -> %f", 
+                      detector, ring, sector, strip, track, edep, hit->Edep(),
+                      hit->Edep() + edep));
       hit->SetEdep(hit->Edep() + edep);
-      return;
+      return hit;
     }
   }
   // If hit wasn't already registered, do so know. 
-  new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, strip, 
-                           x, y, z, px, py, pz, edep, pdg, t);
+  hit = new (a[fNhits]) AliFMDHit(fIshunt, track, detector, ring, sector, 
+                                 strip, x, y, z, px, py, pz, edep, pdg, t, 
+                                 l, stop);
   fNhits++;
+  return hit;
 }
 
 //____________________________________________________________________
@@ -807,12 +1121,15 @@ AliFMD::Hits2Digits()
   // Create AliFMDDigit's from AliFMDHit's.  This is done by making a
   // AliFMDDigitizer, and executing that code.
   // 
+  Warning("Hits2Digits", "Try not to use this method.\n"
+         "Instead, use AliSimulator");
   AliRunDigitizer* manager = new AliRunDigitizer(1, 1);
   manager->SetInputStream(0, "galice.root");
   manager->SetOutputFile("H2Dfile");
   
   /* AliDigitizer* dig =*/ CreateDigitizer(manager);
   manager->Exec("");
+  delete manager;
 }
 
 //____________________________________________________________________
@@ -824,6 +1141,7 @@ AliFMD::Hits2SDigits()
   // 
   AliFMDSDigitizer* digitizer = new AliFMDSDigitizer("galice.root");
   digitizer->Exec("");
+  delete digitizer;
 }
 
   
@@ -865,7 +1183,6 @@ AliFMD::Browse(TBrowser* b)
   //
   AliDebug(30, "\tBrowsing the FMD");
   AliDetector::Browse(b);
-  if (fSimulator) b->Add(fSimulator);
   b->Add(AliFMDGeometry::Instance());
 }