From 6f5308d9b199f75ad2126f9b5af9db8ebde4e81c Mon Sep 17 00:00:00 2001 From: masera Date: Thu, 17 Apr 2008 10:31:04 +0000 Subject: [PATCH] Added protection in case gGeoManager is a null pointer --- ITS/AliITS.cxx | 7 ++++--- ITS/AliITS.h | 2 +- ITS/AliITSLoader.cxx | 5 +++++ ITS/AliITSQASDDDataMakerSim.cxx | 12 ++++++++---- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ITS/AliITS.cxx b/ITS/AliITS.cxx index 9d804f56147..64b386e8bb1 100644 --- a/ITS/AliITS.cxx +++ b/ITS/AliITS.cxx @@ -538,7 +538,7 @@ void AliITS::FillModules(TTree *treeH, Int_t mask) { } //______________________________________________________________________ -void AliITS::InitModules(Int_t size,Int_t &nmodules){ +Bool_t AliITS::InitModules(Int_t size,Int_t &nmodules){ // Initialize the modules array. // Inputs: // Int_t size Size of array of the number of modules to be @@ -556,7 +556,7 @@ void AliITS::InitModules(Int_t size,Int_t &nmodules){ if(!fDetTypeSim) { Error("InitModules","fDetTypeSim is null!"); - return; + return kFALSE; } Int_t nl,indexMAX,index; @@ -564,7 +564,7 @@ void AliITS::InitModules(Int_t size,Int_t &nmodules){ if(size<=0){ // default to using data stored in AliITSgeom if(fDetTypeSim->GetITSgeom()==0) { Error("InitModules","fITSgeom not defined"); - return; + return kFALSE; } // end if fITSgeom==0 nl = fDetTypeSim->GetITSgeom()->GetNlayers(); indexMAX = fDetTypeSim->GetITSgeom()->GetIndexMax(); @@ -581,6 +581,7 @@ void AliITS::InitModules(Int_t size,Int_t &nmodules){ nmodules = size; } // end i size<=0 + return kTRUE; } //______________________________________________________________________ void AliITS::Hits2SDigits(){ diff --git a/ITS/AliITS.h b/ITS/AliITS.h index 0e761f5d627..e7527b484aa 100644 --- a/ITS/AliITS.h +++ b/ITS/AliITS.h @@ -97,7 +97,7 @@ class AliITS : public AliDetector { //------------ sort hits by module for Digitisation ---------------- virtual void FillModules(Int_t evnt,Int_t bgrev,Int_t nmodules, Option_t *opt, const char *filename); - virtual void InitModules(Int_t size,Int_t &nmodules); + virtual Bool_t InitModules(Int_t size,Int_t &nmodules); virtual void FillModules(TTree *treeH, Int_t mask = 0); virtual void ClearModules(){if(fITSmodules) fITSmodules->Delete();} virtual void AddHit(Int_t track, Int_t *vol, Float_t *hits); diff --git a/ITS/AliITSLoader.cxx b/ITS/AliITSLoader.cxx index f71de800175..c1ed5709c44 100644 --- a/ITS/AliITSLoader.cxx +++ b/ITS/AliITSLoader.cxx @@ -17,6 +17,7 @@ #include #include +#include #include "AliITSdigit.h" #include "AliITSLoader.h" @@ -329,6 +330,10 @@ AliITSgeom* AliITSLoader::GetITSgeom(Bool_t force) { delete fGeom; fGeom = 0; } + if(!gGeoManager){ + AliError("gGeoManager is a null pointer - ITS geometry not built"); + return fGeom; + } AliITSInitGeometry initgeom; fGeom = initgeom.CreateAliITSgeom(); AliDebug(1,"AliITSgeom object has been initialized from TGeo\n"); diff --git a/ITS/AliITSQASDDDataMakerSim.cxx b/ITS/AliITSQASDDDataMakerSim.cxx index 274d02fdb2f..a5083176500 100644 --- a/ITS/AliITSQASDDDataMakerSim.cxx +++ b/ITS/AliITSQASDDDataMakerSim.cxx @@ -13,6 +13,8 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ +/* $Id$ */ + // ************************************************************* // Checks the quality assurance // by comparing with reference data @@ -133,7 +135,7 @@ void AliITSQASDDDataMakerSim::InitDigits() void AliITSQASDDDataMakerSim::MakeDigits(TTree * digits) { // Fill QA for DIGIT - SDD - - //printf("AliITSQASDDDataMakerSim::MakeDigits called \n"); + // printf("AliITSQASDDDataMakerSim::MakeDigits called \n"); AliITS *fITS = (AliITS*)gAlice->GetModule("ITS"); fITS->SetTreeAddress(); TClonesArray *iITSdigits = fITS->DigitsAddress(1); @@ -189,7 +191,7 @@ void AliITSQASDDDataMakerSim::InitSDigits() void AliITSQASDDDataMakerSim::MakeSDigits(TTree * sdigits) { // Fill QA for SDIGIT - SDD - - //printf("AliITSQASDDDataMakerSim::MakeSDigits called \n"); + // printf("AliITSQASDDDataMakerSim::MakeSDigits called \n"); AliITSsegmentationSDD* seg = new AliITSsegmentationSDD(); Int_t nan=seg->Npz(); Int_t ntb=seg->Npx(); @@ -265,8 +267,10 @@ void AliITSQASDDDataMakerSim::MakeHits(TTree * hits) AliITS *fITS = (AliITS*)gAlice->GetModule("ITS"); fITS->SetTreeAddress(); Int_t nmodules; - fITS->InitModules(-1,nmodules); - //fITS->FillModules(0,0,nmodules," "," "); + if(!(fITS->InitModules(-1,nmodules))){ + AliError("ITS geometry not available - nothing done"); + return; + } fITS->FillModules(hits,0); -- 2.43.0