]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliMCQA.cxx
Make use of new method AliRawReader::GetNumberOfEvents() - goinf to the last event...
[u/mrichter/AliRoot.git] / STEER / AliMCQA.cxx
index f7415e091ffecac882c615610d91d4ae3cfc2863..e8c15e3bb870814360ffd565d55fcec9619a130e 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Header$ */
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 #include <TList.h>
 #include <TLorentzVector.h>
 #include <TMath.h>
-#include <TMath.h>
 #include <TObjArray.h>
-#include <TPad.h>
 #include <TPaveLabel.h>
 #include <TROOT.h>
+#include <TVirtualMC.h>
 
+#include "AliLog.h"
+#include "AliMC.h"
 #include "AliMCQA.h"
 #include "AliModule.h"
 #include "AliRun.h"
@@ -148,16 +149,22 @@ AliMCQA::AliMCQA(Int_t ndets):
   //
   // Build list of volume names
   //
+  AliMC * mc = gAlice->GetMCApp();
   for(i=0;i<fNvolumes;++i) {
-    AliModule *mod = dynamic_cast<AliModule*>
-      ((*gAlice->Modules())[gAlice->DetFromMate(gMC->VolId2Mate(i+1))]);
-    (*fVolNames)[i]=new TNamed(gMC->VolName(i+1),mod->GetName());
+    Int_t mat = gMC->VolId2Mate(i+1);
+    if (mat > 0) {
+       AliModule *mod = dynamic_cast<AliModule*>
+           ((*gAlice->Modules())[mc->DetFromMate(gMC->VolId2Mate(i+1))]);
+       (*fVolNames)[i] = new TNamed(gMC->VolName(i+1),mod->GetName());
+    } else {
+       (*fVolNames)[i] = new TNamed(gMC->VolName(i+1), "Assembly");
+    }
   }
 
   fQAHist->Add(new TH1F("hMCMcalls","Monte Carlo calls per module",
                        fNdets, -0.5, fNdets-0.5));
   h = dynamic_cast<TH1F*>(dir->FindObject("hMCMcalls"));
-   h->GetListOfFunctions()->Add(new TExec("ex","gAlice->GetMCQA()->AddModuleName()"));
+  h->GetListOfFunctions()->Add(new TExec("ex","gAlice->GetMCQA()->AddModuleName()"));
 
   dir->Remove(dir->FindObject("hMCMcalls"));
   //
@@ -169,37 +176,41 @@ AliMCQA::AliMCQA(Int_t ndets):
 }
 
 //_______________________________________________________________________
-void AliMCQA::Copy(AliMCQA &) const
+void AliMCQA::Copy(TObject &) const
 {
-  Fatal("Copy ctor","Not implemented!\n");
+  AliFatal("Not implemented!");
 }
 
 //_______________________________________________________________________
 AliMCQA::~AliMCQA() 
-{
+ {
   //
   // Destructor
   //
   gROOT->GetListOfBrowsables()->Remove(this);
+  //if program crashes here - it probobly means that 
+  //one of added browsables was deleted and not removed previously from that list
+  //skowron
+  
   if (fQAList) {
     fQAList->Delete();
     delete fQAList;
-    fQAList=0;
+    fQAList = 0;
   }
   if (fQAHist) {
     fQAHist->Delete();
     delete fQAHist;
-    fQAHist=0;
+    fQAHist = 0;
   }
   if (fVolNames) {
     fVolNames->Delete();
     delete fVolNames;
-    fVolNames=0;
+    fVolNames = 0;
   }
   if (fModNames) {
     fModNames->Delete();
     delete fModNames;
-    fModNames=0;
+    fModNames = 0;
   }
   delete [] fDetDone;
   delete fMPaveLabel;
@@ -270,7 +281,7 @@ void AliMCQA::StepManager(Int_t id)
     static  Double_t mpim=0;
     static  Double_t mep=0;
     static  Double_t mem=0;
-    Double_t mass=0;
+    Double_t mass = 0;
     Int_t num = gMC->TrackPid();
 
     switch (num) {
@@ -295,7 +306,8 @@ void AliMCQA::StepManager(Int_t id)
       mass=mem;
       break;
     default:
-      mass =gAlice->PDGDB()->GetParticle(num)->Mass();
+       if (gAlice->PDGDB()->GetParticle(num))
+           mass = gAlice->PDGDB()->GetParticle(num)->Mass();
       break; 
     }