X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliRun.cxx;h=b3ac1f43eaa24ce8da79e5924bad1088d8e02f3a;hb=44dbae42b86ea9efebff5c700c16bcf10ec5c619;hp=8b3bb4e850a687ad55450dd7d3f07f37c2280a92;hpb=85f621711a2e64f0cd35e8b7ae34b3899a9d82e6;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliRun.cxx b/STEER/AliRun.cxx index 8b3bb4e850a..b3ac1f43eaa 100644 --- a/STEER/AliRun.cxx +++ b/STEER/AliRun.cxx @@ -49,6 +49,7 @@ #include #include #include +#include // #include "AliLog.h" #include "AliDetector.h" @@ -63,9 +64,8 @@ #include "AliPDG.h" #include "AliRun.h" #include "AliStack.h" -#ifdef __APPLE__ -#include "AliTPCTrackHitsInterfaces.h" -#endif +#include "AliCDBManager.h" +#include "AliAlignObj.h" AliRun *gAlice; @@ -82,13 +82,17 @@ AliRun::AliRun(): fMCApp(0), fDisplay(0), fField(0), - fMC(0), fNdets(0), fInitDone(kFALSE), fLego(0), fPDGDB(0), //Particle factory object - fConfigFunction("\0"), + fConfigFunction(""), fRandom(0), + fBaseFileName(""), + fIsRootGeometry(kFALSE), + fGeometryFromCDB(kFALSE), + fGeometryFileName(""), + fTriggerDescriptor(""), fRunLoader(0x0) { // @@ -110,13 +114,17 @@ AliRun::AliRun(const AliRun& arun): fMCApp(0), fDisplay(0), fField(0), - fMC(0), fNdets(0), fInitDone(kFALSE), fLego(0), fPDGDB(0), //Particle factory object fConfigFunction("\0"), fRandom(0), + fBaseFileName(""), + fIsRootGeometry(kFALSE), + fGeometryFromCDB(kFALSE), + fGeometryFileName(""), + fTriggerDescriptor(""), fRunLoader(0x0) { // @@ -137,13 +145,17 @@ AliRun::AliRun(const char *name, const char *title): fMCApp(0), fDisplay(0), fField(0), - fMC(gMC), fNdets(0), fInitDone(kFALSE), fLego(0), fPDGDB(TDatabasePDG::Instance()), //Particle factory object! fConfigFunction("Config();"), fRandom(new TRandom3()), + fBaseFileName(""), + fIsRootGeometry(kFALSE), + fGeometryFromCDB(kFALSE), + fGeometryFileName(""), + fTriggerDescriptor(""), fRunLoader(0x0) { // @@ -164,8 +176,6 @@ AliRun::AliRun(const char *name, const char *title): // Add to list of browsable gROOT->GetListOfBrowsables()->Add(this,name); - // Create the TNode geometry for the event display - BuildSimpleGeometry(); // Create default mag field SetField(); @@ -173,14 +183,6 @@ AliRun::AliRun(const char *name, const char *title): // Add particle list to configuration AliConfig::Instance()->Add(fPDGDB); -#ifdef __APPLE__ - // Terrible hack to avoid problem with the initialisation of - // static and globals on Mac OS X - AliClassAliTrackHitsInfo p1=galiclass____AliClassAliTrackHitsInfo; - AliClassAliTrackHitsParam p2=galiclass____AliTrackHitsParam; - AliClassAliHitInfo p3=galiclass____AliHitInfo; -#endif - } @@ -280,6 +282,29 @@ void AliRun::SetField(AliMagF* magField) fField->ReadField(); } +//_______________________________________________________________________ +void AliRun::SetRootGeometry(Bool_t flag) +{ +// Instruct application that the geometry is to be retreived from a root file. + fIsRootGeometry = flag; + if (flag && gMC) gMC->SetRootGeometry(); +} + +//_______________________________________________________________________ +void AliRun::SetGeometryFromCDB() +{ + // Set the loading of geometry from cdb instead of creating it + // A default CDB storage needs to be set before this method is called + if(AliCDBManager::Instance()->IsDefaultStorageSet()){ + SetRootGeometry(); + fGeometryFromCDB = kTRUE; + }else{ + AliError("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + AliError("Loading of geometry from CDB ignored. First set a default CDB storage!"); + AliError("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + } +} + //_______________________________________________________________________ void AliRun::SetField(Int_t type, Int_t version, Float_t scale, Float_t maxField, const char* filename) @@ -334,7 +359,7 @@ void AliRun::FinishRun() // // Called at the end of the run. // - + if(fLego) { AliDebug(1, "Finish Lego"); @@ -358,12 +383,7 @@ void AliRun::FinishRun() Write(0,TObject::kOverwrite);//write AliRun fRunLoader->Write(0,TObject::kOverwrite);//write RunLoader itself - // Clean tree information - AliDebug(1, "fRunLoader->Stack()->FinishRun()"); - fRunLoader->Stack()->FinishRun(); - - if(fMCApp) fMCApp->FinishRun(); - + if(fMCApp) fMCApp->FinishRun(); fRunLoader->Synchronize(); } @@ -451,8 +471,8 @@ Int_t AliRun::GetEvent(Int_t event) // Set Trees branch addresses TIter next(fModules); - AliModule *detector; - while((detector = dynamic_cast(next()))) + AliDetector *detector; + while((detector = dynamic_cast(next()))) { detector->SetTreeAddress(); } @@ -463,27 +483,28 @@ Int_t AliRun::GetEvent(Int_t event) //_______________________________________________________________________ TGeometry *AliRun::GetGeometry() { - // - // Import Alice geometry from current file - // Return pointer to geometry object - // - if (!fGeometry) fGeometry = dynamic_cast(gDirectory->Get("AliceGeom")); - // - // Unlink and relink nodes in detectors - // This is bad and there must be a better way... - // + + // Create the TNode geometry for the event display + if (!fGeometry) { + BuildSimpleGeometry(); + // + // Unlink and relink nodes in detectors + // This is bad and there must be a better way... + // - TIter next(fModules); - AliModule *detector; - while((detector = dynamic_cast(next()))) { - TList *dnodes=detector->Nodes(); - Int_t j; - TNode *node, *node1; - for ( j=0; jGetSize(); j++) { - node = dynamic_cast(dnodes->At(j)); - node1 = fGeometry->GetNode(node->GetName()); - dnodes->Remove(node); - dnodes->AddAt(node1,j); + TIter next(fModules); + AliModule *detector; + while((detector = dynamic_cast(next()))) { + detector->BuildGeometry(); + TList *dnodes=detector->Nodes(); + Int_t j; + TNode *node, *node1; + for ( j=0; jGetSize(); j++) { + node = dynamic_cast(dnodes->At(j)); + node1 = fGeometry->GetNode(node->GetName()); + dnodes->Remove(node); + dnodes->AddAt(node1,j); + } } } return fGeometry; @@ -555,12 +576,15 @@ void AliRun::InitMC(const char *setup) gROOT->LoadMacro(setup); gInterpreter->ProcessLine(fConfigFunction.Data()); + // Set the run number in the CDB manager as assigned from + // constructor or from config file + AliCDBManager::Instance()->SetRun(GetRunNumber()); + fRunLoader->CdGAFile(); - + AliPDG::AddParticlesToPdgDataBase(); fNdets = fModules->GetLast()+1; - TIter next(fModules); for(Int_t i=0; iSetRadiusRange(rmin, rmax); gener->SetZMax(zmax); gener->SetCoor1Range(nc1, c1min, c1max); @@ -796,9 +823,9 @@ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min, //Run Lego Object - if (fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nc1 * nc2); - //gMC->ProcessRun(nc1*nc2+1); - gMC->ProcessRun(nc1*nc2); + + if (fRunLoader) fRunLoader->SetNumberOfEventsPerFile(nev); + gMC->ProcessRun(nev); // End of this run, close files FinishRun(); @@ -828,10 +855,12 @@ void AliRun::Field(const Double_t* x, Double_t *b) const // // Return the value of the magnetic field // + Float_t xfloat[3]; for (Int_t i=0; i<3; i++) xfloat[i] = x[i]; if (Field()) { + Float_t bfloat[3]; Field()->Field(xfloat,bfloat); for (Int_t j=0; j<3; j++) b[j] = bfloat[j]; @@ -840,6 +869,8 @@ void AliRun::Field(const Double_t* x, Double_t *b) const AliError("No mag field defined!"); b[0]=b[1]=b[2]=0.; } + + } // @@ -949,17 +980,14 @@ void AliRun::AddModule(AliModule* mod) fNdets++; } +// added by Alberto Colla +//_____________________________________________________________________________ +/*inline*/ Bool_t AliRun::IsFileAccessible(const char* fnam, EAccessMode mode) +{ return !gSystem->AccessPathName(fnam,mode);} -//_______________________________________________________________________ -Int_t AliRun::GetDebug() const -{ - AliWarning("Don't use this method any more, use AliDebug instead"); - return AliDebugLevel(); -} - -//_______________________________________________________________________ -void AliRun::SetDebug(Int_t level) +//______________________________________________________ +/*inline*/ Bool_t AliRun::IsFileAccessible(Char_t* name,EAccessMode mode) { - AliWarning("Don't use this method any more, use AliLog instead"); - AliLog::SetClassDebugLevel("AliRun", level); + TString str = name; gSystem->ExpandPathName(str); + return !gSystem->AccessPathName(str.Data(),mode); }