X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliRun.cxx;h=9a88b014bd3f9d181b8afa9a5f9715eea62a2779;hb=f5bc14853de66388dae5300a43f945c59eece4ba;hp=5ce56e1003559bec5a711ef999e71a899b904f02;hpb=b9d0a01d7a0723a09071b0b56200d72f59a9c2b6;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliRun.cxx b/STEER/AliRun.cxx index 5ce56e10035..9a88b014bd3 100644 --- a/STEER/AliRun.cxx +++ b/STEER/AliRun.cxx @@ -13,220 +13,7 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* -$Log$ -Revision 1.82.4.3 2002/10/14 09:45:57 hristov -Updating VirtualMC to v3-09-02 - -Revision 1.82.4.2 2002/06/10 17:54:06 hristov -Only one SetGenEventHeader function kept - -Revision 1.82.4.1 2002/06/10 14:43:06 hristov -Merged with v3-08-02 - -Revision 1.86 2002/05/28 14:24:57 hristov -Correct warning messages - -Revision 1.85 2002/05/24 13:29:58 hristov -AliTrackReference added, AliDisplay modified - -Revision 1.84 2002/05/21 16:26:07 hristov -Find correctly TreeK in case CONFIG_SPLIT_FILE is set (Y.Schutz) - -Revision 1.83 2002/04/04 13:16:17 jchudoba -add possibility to write sdigits, digits and rec. points into separate files - -Revision 1.82 2002/03/12 11:06:03 morsch -Add particle status code to argument list of SetTrack(..). - -Revision 1.81 2001/12/19 14:46:26 morsch -Add possibility to disable StepManager() for each module separately. - -Revision 1.80 2001/10/21 18:22:55 hristov -BranchOld replaced by Branch. It works correctly with Root 2.02.xx - -Revision 1.79 2001/10/09 18:00:35 hristov -Temporary fix to provide unique event number in the simulation (J.Chudoba) - -Revision 1.78 2001/10/04 15:30:56 hristov -Changes to accommodate the set of PHOS folders and tasks (Y.Schutz) - -Revision 1.77 2001/09/04 15:09:11 hristov -fTreeE->Branch replaced temporary by fTreeE->BranchOld to avoid data corruption in case of many events per file - -Revision 1.76 2001/08/03 14:38:35 morsch -Use original method to access TreeH. - -Revision 1.75 2001/07/28 10:52:27 hristov -Event number updated correctly (M.Ivanov) - -Revision 1.74 2001/07/28 10:39:16 morsch -GetEventsPerRun() method needed by afterburners added to AliRun.h -Corresponding setters and getters have been from AliGenerator. - -Revision 1.73 2001/07/27 12:34:30 jchudoba -remove the dummy argument in fStack->GetEvent call - -Revision 1.72 2001/07/03 08:10:57 hristov -J.Chudoba's changes merged correctly with the HEAD - -Revision 1.70 2001/06/29 08:01:36 morsch -Small correction to the previous. - -Revision 1.69 2001/06/28 16:27:50 morsch -AliReco() with user control of event range. - -Revision 1.68 2001/06/11 13:14:40 morsch -SetAliGenEventHeader() method added. - -Revision 1.67 2001/06/07 18:24:50 buncic -Removed compilation warning in AliConfig initialisation. - -Revision 1.66 2001/05/22 14:32:40 hristov -Weird inline removed - -Revision 1.65 2001/05/21 17:22:51 buncic -Fixed problem with missing AliConfig while reading galice.root - -Revision 1.64 2001/05/16 14:57:22 alibrary -New files for folders and Stack - -Revision 1.62 2001/04/06 11:12:33 morsch -Clear fParticles after each event. (Ivana Hrivnacova) - -Revision 1.61 2001/03/30 07:04:10 morsch -Call fGenerator->FinishRun() for final print-outs, cross-section and weight calculations. - -Revision 1.60 2001/03/21 18:22:30 hristov -fParticleFileMap fix (I.Hrivnacova) - -Revision 1.59 2001/03/12 17:47:03 hristov -Changes needed on Sun with CC 5.0 - -Revision 1.58 2001/03/09 14:27:26 morsch -Fix for multiple events per file: inhibit decrease of size of fParticleFileMap. - -Revision 1.57 2001/02/23 17:40:23 buncic -All trees needed for simulation created in RunMC(). TreeR and its branches -are now created in new RunReco() method. - -Revision 1.56 2001/02/14 15:45:20 hristov -Algorithmic way of getting entry index in fParticleMap. Protection of fParticleFileMap (I.Hrivnacova) - -Revision 1.55 2001/02/12 15:52:54 buncic -Removed OpenBaseFile(). - -Revision 1.54 2001/02/07 10:39:05 hristov -Remove default value for argument - -Revision 1.53 2001/02/06 11:02:26 hristov -New SetTrack interface added, added check for unfilled particles in FinishEvent (I.Hrivnacova) - -Revision 1.52 2001/02/05 16:22:25 buncic -Added TreeS to GetEvent(). - -Revision 1.51 2001/02/02 15:16:20 morsch -SetHighWaterMark method added to mark last particle in event. - -Revision 1.50 2001/01/27 10:32:00 hristov -Leave the loop when primaries are filled (I.Hrivnacova) - -Revision 1.49 2001/01/26 19:58:48 hristov -Major upgrade of AliRoot code - -Revision 1.48 2001/01/17 10:50:50 hristov -Corrections to destructors - -Revision 1.47 2000/12/18 10:44:01 morsch -Possibility to set field map by passing pointer to objet of type AliMagF via -SetField(). -Example: -gAlice->SetField(new AliMagFCM("Map2", "$(ALICE_ROOT)/data/field01.dat",2,1.,10.)); - -Revision 1.46 2000/12/14 19:29:27 fca -galice.cuts was not read any more - -Revision 1.45 2000/11/30 07:12:49 alibrary -Introducing new Rndm and QA classes - -Revision 1.44 2000/10/26 13:58:59 morsch -Add possibility to choose the lego generator (of type AliGeneratorLego or derived) when running -RunLego(). Default is the base class AliGeneratorLego. - -Revision 1.43 2000/10/09 09:43:17 fca -Special remapping of hits for TPC and TRD. End-of-primary action introduced - -Revision 1.42 2000/10/02 21:28:14 fca -Removal of useless dependecies via forward declarations - -Revision 1.41 2000/07/13 16:19:09 fca -Mainly coding conventions + some small bug fixes - -Revision 1.40 2000/07/12 08:56:25 fca -Coding convention correction and warning removal - -Revision 1.39 2000/07/11 18:24:59 fca -Coding convention corrections + few minor bug fixes - -Revision 1.38 2000/06/20 13:05:45 fca -Writing down the TREE headers before job starts - -Revision 1.37 2000/06/09 20:05:11 morsch -Introduce possibility to chose magnetic field version 3: AliMagFDM + field02.dat - -Revision 1.36 2000/06/08 14:03:58 hristov -Only one initializer for a default argument - -Revision 1.35 2000/06/07 10:13:14 hristov -Delete only existent objects. - -Revision 1.34 2000/05/18 10:45:38 fca -Delete Particle Factory properly - -Revision 1.33 2000/05/16 13:10:40 fca -New method IsNewTrack and fix for a problem in Father-Daughter relations - -Revision 1.32 2000/04/27 10:38:21 fca -Correct termination of Lego Run and introduce Lego getter in AliRun - -Revision 1.31 2000/04/26 10:17:32 fca -Changes in Lego for G4 compatibility - -Revision 1.30 2000/04/18 19:11:40 fca -Introduce variable Config.C function signature - -Revision 1.29 2000/04/07 11:12:34 fca -G4 compatibility changes - -Revision 1.28 2000/04/05 06:51:06 fca -Workaround for an HP compiler problem - -Revision 1.27 2000/03/22 18:08:07 fca -Rationalisation of the virtual MC interfaces - -Revision 1.26 2000/03/22 13:42:26 fca -SetGenerator does not replace an existing generator, ResetGenerator does - -Revision 1.25 2000/02/23 16:25:22 fca -AliVMC and AliGeant3 classes introduced -ReadEuclid moved from AliRun to AliModule - -Revision 1.24 2000/01/19 17:17:20 fca -Introducing a list of lists of hits -- more hits allowed for detector now - -Revision 1.23 1999/12/03 11:14:31 fca -Fixing previous wrong checking - -Revision 1.21 1999/11/25 10:40:08 fca -Fixing daughters information also in primary tracks - -Revision 1.20 1999/10/04 18:08:49 fca -Adding protection against inconsistent Euclid files - -Revision 1.19 1999/09/29 07:50:40 fca -Introduction of the Copyright and cvs Log - -*/ +/* $Id$ */ /////////////////////////////////////////////////////////////////////////////// // // @@ -253,97 +40,190 @@ Introduction of the Copyright and cvs Log // // /////////////////////////////////////////////////////////////////////////////// -#include #include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "Riostream.h" +#include "TBRIK.h" +#include "TBrowser.h" +#include "TCint.h" +#include "TFile.h" +#include "TFolder.h" +#include "TGeometry.h" +#include "TNode.h" #include "TParticle.h" -#include "AliRun.h" +#include "TRandom3.h" +#include "TROOT.h" +#include "TSystem.h" +#include "TTree.h" + +#include "AliConfig.h" +#include "AliDetector.h" #include "AliDisplay.h" -#include "AliMC.h" +#include "AliGenerator.h" +#include "AliHeader.h" #include "AliLego.h" +#include "AliLegoGenerator.h" +#include "AliMCQA.h" #include "AliMagFC.h" #include "AliMagFCM.h" #include "AliMagFDM.h" -#include "AliHit.h" -#include "TRandom3.h" -#include "AliMCQA.h" -#include "AliGenerator.h" -#include "AliLegoGenerator.h" -#include "AliConfig.h" +#include "AliPDG.h" +#include "AliRun.h" #include "AliStack.h" -#include "AliGenEventHeader.h" -#include "AliHeader.h" - -#include "AliDetector.h" AliRun *gAlice; ClassImp(AliRun) -//_____________________________________________________________________________ -AliRun::AliRun() - : TVirtualMCApplication() +//_______________________________________________________________________ +AliRun::AliRun(): + fRun(0), + fEvent(0), + fEventNrInRun(0), + fEventsPerRun(0), + fDebug(0), + fHeader(0), + fTreeD(0), + fTreeS(0), + fTreeH(0), + fTreeTR(0), + fTreeE(0), + fTreeR(0), + fModules(0), + fGeometry(0), + fDisplay(0), + fTimer(), + fField(0), + fMC(0), + fImedia(0), + fNdets(0), + fTrRmax(1.e10), + fTrZmax(1.e10), + fGenerator(0), + fInitDone(kFALSE), + fLego(0), + fPDGDB(0), //Particle factory object + fHitLists(0), + fEventEnergy(0), + fSummEnergy(0), + fSum2Energy(0), + fConfigFunction("\0"), + fRandom(0), + fMCQA(0), + fTransParName("\0"), + fBaseFileName("\0"), + fStack(0), + fTreeDFileName(""), + fTreeDFile(0), + fTreeSFileName(""), + fTreeSFile(0), + fTreeRFileName(""), + fTreeRFile(0) { // // Default constructor for AliRun // - fHeader = 0; - fRun = 0; - fEvent = 0; - fEventNrInRun = 0; - fStack = 0; - fModules = 0; - fGenerator = 0; - fTreeD = 0; - fTreeH = 0; - fTreeTR = 0; - fTreeE = 0; - fTreeR = 0; - fTreeS = 0; - fGeometry = 0; - fDisplay = 0; - fField = 0; - fMC = 0; - fNdets = 0; - fImedia = 0; - fTrRmax = 1.e10; - fTrZmax = 1.e10; - fInitDone = kFALSE; - fLego = 0; - fPDGDB = 0; //Particle factory object! - fHitLists = 0; - fConfigFunction = "\0"; - fRandom = 0; - fMCQA = 0; - fTransParName = "\0"; - fBaseFileName = ".\0"; - fDebug = 0; - fTreeDFile = 0; - fTreeSFileName = ""; - fTreeSFile = 0; - fTreeSFileName = ""; - fTreeRFile = 0; - fTreeRFileName = ""; +} + +//_______________________________________________________________________ +AliRun::AliRun(const AliRun& arun): + TVirtualMCApplication(arun), + fRun(0), + fEvent(0), + fEventNrInRun(0), + fEventsPerRun(0), + fDebug(0), + fHeader(0), + fTreeD(0), + fTreeS(0), + fTreeH(0), + fTreeTR(0), + fTreeE(0), + fTreeR(0), + fModules(0), + fGeometry(0), + fDisplay(0), + fTimer(), + fField(0), + fMC(0), + fImedia(0), + fNdets(0), + fTrRmax(1.e10), + fTrZmax(1.e10), + fGenerator(0), + fInitDone(kFALSE), + fLego(0), + fPDGDB(0), //Particle factory object + fHitLists(0), + fEventEnergy(0), + fSummEnergy(0), + fSum2Energy(0), + fConfigFunction("\0"), + fRandom(0), + fMCQA(0), + fTransParName("\0"), + fBaseFileName("\0"), + fStack(0), + fTreeDFileName(""), + fTreeDFile(0), + fTreeSFileName(""), + fTreeSFile(0), + fTreeRFileName(""), + fTreeRFile(0) +{ + // + // Copy constructor for AliRun + // + arun.Copy(*this); } //_____________________________________________________________________________ -AliRun::AliRun(const char *name, const char *title) - : TVirtualMCApplication(name,title) +AliRun::AliRun(const char *name, const char *title): + TVirtualMCApplication(name,title), + fRun(0), + fEvent(0), + fEventNrInRun(0), + fEventsPerRun(0), + fDebug(0), + fHeader(new AliHeader()), + fTreeD(0), + fTreeS(0), + fTreeH(0), + fTreeTR(0), + fTreeE(0), + fTreeR(0), + fModules(new TObjArray(77)), // Support list for the Detectors + fGeometry(0), + fDisplay(0), + fTimer(), + fField(0), + fMC(gMC), + fImedia(new TArrayI(1000)), + fNdets(0), + fTrRmax(1.e10), + fTrZmax(1.e10), + fGenerator(0), + fInitDone(kFALSE), + fLego(0), + fPDGDB(TDatabasePDG::Instance()), //Particle factory object! + fHitLists(new TList()), // Create HitLists list + fEventEnergy(0), + fSummEnergy(0), + fSum2Energy(0), + fConfigFunction("Config();"), + fRandom(new TRandom3()), + fMCQA(0), + fTransParName("\0"), + fBaseFileName("\0"), + fStack(new AliStack(10000)), //Particle stack + fTreeDFileName(""), + fTreeDFile(0), + fTreeSFileName(""), + fTreeSFile(0), + fTreeRFileName(""), + fTreeRFile(0) { // // Constructor for the main processor. @@ -351,79 +231,37 @@ AliRun::AliRun(const char *name, const char *title) // Creates the list of Detectors. // Creates the list of particles. // - Int_t i; - + gAlice = this; - fTreeD = 0; - fTreeH = 0; - fTreeTR = 0; - fTreeE = 0; - fTreeR = 0; - fTreeS = 0; - fTrRmax = 1.e10; - fTrZmax = 1.e10; - fGenerator = 0; - fInitDone = kFALSE; - fLego = 0; - fField = 0; - fConfigFunction = "Config();"; - fTreeDFile = 0; - fTreeSFileName = ""; - fTreeSFile = 0; - fTreeSFileName = ""; - fTreeRFile = 0; - fTreeRFileName = ""; // Set random number generator - gRandom = fRandom = new TRandom3(); + gRandom = fRandom; if (gSystem->Getenv("CONFIG_SEED")) { - gRandom->SetSeed((UInt_t)atoi(gSystem->Getenv("CONFIG_SEED"))); + gRandom->SetSeed(static_cast(atoi(gSystem->Getenv("CONFIG_SEED")))); } - + + // Add to list of browsable gROOT->GetListOfBrowsables()->Add(this,name); - // - // Particle stack - fStack = new AliStack(10000); - // create the support list for the various Detectors - fModules = new TObjArray(77); - // + // Create the TNode geometry for the event display - BuildSimpleGeometry(); - fHeader = new AliHeader(); - fRun = 0; - fEvent = 0; - fEventNrInRun = 0; - // - fDisplay = 0; - // // Create default mag field SetField(); - // - fMC = gMC; - // + // Prepare the tracking medium lists - fImedia = new TArrayI(1000); - for(i=0;i<1000;i++) (*fImedia)[i]=-99; - // - // Make particles - fPDGDB = TDatabasePDG::Instance(); //Particle factory object! + for(Int_t i=0;i<1000;i++) (*fImedia)[i]=-99; + // Add particle list to configuration AliConfig::Instance()->Add(fPDGDB); - // - // Create HitLists list - fHitLists = new TList(); - // + + // Set transport parameters SetTransPar(); - fBaseFileName = ".\0"; - // - fDebug = 0; } -//_____________________________________________________________________________ +//_______________________________________________________________________ AliRun::~AliRun() { // @@ -433,7 +271,8 @@ AliRun::~AliRun() if(fTreeE)curfil=fTreeE->GetCurrentFile(); delete fImedia; delete fField; - delete fMC; + // delete fMC; + delete gMC; gMC=0; delete fGeometry; delete fDisplay; delete fGenerator; @@ -479,27 +318,36 @@ AliRun::~AliRun() gAlice=0; } -//_____________________________________________________________________________ +//_______________________________________________________________________ +void AliRun::Copy(AliRun &) const +{ + // + // Copy method ... not implemented + // + Fatal("Copy","Not implemented!\n"); +} + +//_______________________________________________________________________ void AliRun::AddHit(Int_t id, Int_t track, Int_t *vol, Float_t *hits) const { // // Add a hit to detector id // TObjArray &dets = *fModules; - if(dets[id]) ((AliModule*) dets[id])->AddHit(track,vol,hits); + if(dets[id]) dynamic_cast(dets[id])->AddHit(track,vol,hits); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::AddDigit(Int_t id, Int_t *tracks, Int_t *digits) const { // // Add digit to detector id // TObjArray &dets = *fModules; - if(dets[id]) ((AliModule*) dets[id])->AddDigit(tracks,digits); + if(dets[id]) dynamic_cast(dets[id])->AddDigit(tracks,digits); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Browse(TBrowser *b) { // @@ -520,13 +368,13 @@ void AliRun::Browse(TBrowser *b) TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { b->Add(detector,detector->GetName()); } b->Add(fMCQA,"AliMCQA"); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Build() { // @@ -535,7 +383,7 @@ void AliRun::Build() // } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::BuildSimpleGeometry() { // @@ -550,7 +398,7 @@ void AliRun::BuildSimpleGeometry() new TNode("alice","alice","S_alice"); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::CleanDetectors() { // @@ -558,13 +406,13 @@ void AliRun::CleanDetectors() // TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->FinishEvent(); } } -//_____________________________________________________________________________ -Int_t AliRun::DistancetoPrimitive(Int_t, Int_t) +//_______________________________________________________________________ +Int_t AliRun::DistancetoPrimitive(Int_t, Int_t) const { // // Return the distance from the mouse to the AliRun object @@ -573,7 +421,7 @@ Int_t AliRun::DistancetoPrimitive(Int_t, Int_t) return 9999; } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::DumpPart (Int_t i) const { // @@ -582,7 +430,7 @@ void AliRun::DumpPart (Int_t i) const fStack->DumpPart(i); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::DumpPStack () const { // @@ -591,7 +439,7 @@ void AliRun::DumpPStack () const fStack->DumpPStack(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetField(AliMagF* magField) { // Set Magnetic Field Map @@ -599,7 +447,7 @@ void AliRun::SetField(AliMagF* magField) fField->ReadField(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetField(Int_t type, Int_t version, Float_t scale, Float_t maxField, char* filename) { @@ -626,7 +474,7 @@ void AliRun::SetField(Int_t type, Int_t version, Float_t scale, } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::FinishRun() { // @@ -639,7 +487,7 @@ void AliRun::FinishRun() // Clean detector information TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->FinishRun(); } @@ -683,7 +531,7 @@ void AliRun::FinishRun() file->Write(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::FlagTrack(Int_t track) { // Delegate to stack @@ -691,7 +539,7 @@ void AliRun::FlagTrack(Int_t track) fStack->FlagTrack(track); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::EnergySummary() { // @@ -720,7 +568,7 @@ void AliRun::EnergySummary() } else ed2=99; fSummEnergy[ndep]=ed; - fSum2Energy[ndep]=TMath::Min((Float_t) 99.,TMath::Max(ed2,kzero)); + fSum2Energy[ndep]=TMath::Min(static_cast(99.),TMath::Max(ed2,kzero)); edtot+=ed; ndep++; } @@ -757,25 +605,46 @@ void AliRun::EnergySummary() // fSum2Energy.Set(0); } -//_____________________________________________________________________________ +//_______________________________________________________________________ +void AliRun::Announce() const +{ + // + // Announce the current version of AliRoot + // + printf("%70s", + "****************************************************************\n"); + printf("%6s","*");printf("%64s","*\n"); + + printf("%6s","*"); + printf(" You are running AliRoot version v3-09-07\n"); + + printf("%6s","*"); + printf(" The cvs tag for the current program is $Name$\n"); + + printf("%6s","*");printf("%64s","*\n"); + printf("%70s", + "****************************************************************\n"); +} + +//_______________________________________________________________________ AliModule *AliRun::GetModule(const char *name) const { // // Return pointer to detector from name // - return (AliModule*)fModules->FindObject(name); + return dynamic_cast(fModules->FindObject(name)); } -//_____________________________________________________________________________ +//_______________________________________________________________________ AliDetector *AliRun::GetDetector(const char *name) const { // // Return pointer to detector from name // - return (AliDetector*)fModules->FindObject(name); + return dynamic_cast(fModules->FindObject(name)); } -//_____________________________________________________________________________ +//_______________________________________________________________________ Int_t AliRun::GetModuleID(const char *name) const { // @@ -787,7 +656,7 @@ Int_t AliRun::GetModuleID(const char *name) const return i; } -//_____________________________________________________________________________ +//_______________________________________________________________________ Int_t AliRun::GetEvent(Int_t event) { // @@ -842,20 +711,20 @@ Int_t AliRun::GetEvent(Int_t event) // Get Hits Tree header from file sprintf(treeName,"TreeH%d",event); - fTreeH = (TTree*)gDirectory->Get(treeName); + fTreeH = dynamic_cast(gDirectory->Get(treeName)); if (!fTreeH) { Warning("GetEvent","cannot find Hits Tree for event:%d\n",event); } // Get TracReferences Tree header from file sprintf(treeName,"TreeTR%d",event); - fTreeTR = (TTree*)gDirectory->Get(treeName); + fTreeTR = dynamic_cast(gDirectory->Get(treeName)); if (!fTreeTR) { Warning("GetEvent","cannot find TrackReferences Tree for event:%d\n",event); } // get current file name and compare with names containing trees S,D,R - TString curfilname=(TString)fTreeE->GetCurrentFile()->GetName(); + TString curfilname=static_cast(fTreeE->GetCurrentFile()->GetName()); if(fTreeDFileName==curfilname)fTreeDFileName=""; if(fTreeSFileName==curfilname)fTreeSFileName=""; if(fTreeRFileName==curfilname)fTreeRFileName=""; @@ -867,9 +736,9 @@ Int_t AliRun::GetEvent(Int_t event) InitTreeFile("D",fTreeDFileName); } if (fTreeDFile) { - fTreeD = (TTree*)fTreeDFile->Get(treeName); + fTreeD = dynamic_cast(fTreeDFile->Get(treeName)); } else { - fTreeD = (TTree*)file->Get(treeName); + fTreeD = dynamic_cast(file->Get(treeName)); } if (!fTreeD) { // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event); @@ -893,9 +762,9 @@ Int_t AliRun::GetEvent(Int_t event) InitTreeFile("S",fTreeSFileName); } if (fTreeSFile) { - fTreeS = (TTree*)fTreeSFile->Get(treeName); + fTreeS = dynamic_cast(fTreeSFile->Get(treeName)); } else { - fTreeS = (TTree*)gDirectory->Get(treeName); + fTreeS = dynamic_cast(gDirectory->Get(treeName)); } if (!fTreeS) { // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event); @@ -916,9 +785,9 @@ Int_t AliRun::GetEvent(Int_t event) InitTreeFile("R",fTreeRFileName); } if(fTreeRFile) { - fTreeR = (TTree*)fTreeRFile->Get(treeName); + fTreeR = dynamic_cast(fTreeRFile->Get(treeName)); } else { - fTreeR = (TTree*)gDirectory->Get(treeName); + fTreeR = dynamic_cast(gDirectory->Get(treeName)); } if (!fTreeR) { // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event); @@ -929,7 +798,7 @@ Int_t AliRun::GetEvent(Int_t event) // Set Trees branch addresses TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->SetTreeAddress(); } @@ -938,14 +807,14 @@ Int_t AliRun::GetEvent(Int_t event) return fHeader->GetNtrack(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ TGeometry *AliRun::GetGeometry() { // // Import Alice geometry from current file // Return pointer to geometry object // - if (!fGeometry) fGeometry = (TGeometry*)gDirectory->Get("AliceGeom"); + if (!fGeometry) fGeometry = dynamic_cast(gDirectory->Get("AliceGeom")); // // Unlink and relink nodes in detectors // This is bad and there must be a better way... @@ -953,12 +822,12 @@ TGeometry *AliRun::GetGeometry() TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { TList *dnodes=detector->Nodes(); Int_t j; TNode *node, *node1; for ( j=0; jGetSize(); j++) { - node = (TNode*) dnodes->At(j); + node = dynamic_cast(dnodes->At(j)); node1 = fGeometry->GetNode(node->GetName()); dnodes->Remove(node); dnodes->AddAt(node1,j); @@ -967,7 +836,7 @@ TGeometry *AliRun::GetGeometry() return fGeometry; } -//_____________________________________________________________________________ +//_______________________________________________________________________ Int_t AliRun::GetPrimary(Int_t track) const { // @@ -976,7 +845,7 @@ Int_t AliRun::GetPrimary(Int_t track) const return fStack->GetPrimary(track); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::MediaTable() { // @@ -991,7 +860,7 @@ void AliRun::MediaTable() // For all detectors for (kz=0;kz(dets[kz]))) { TArrayI &idtmed = *(det->GetIdtmed()); for(nz=0;nz<100;nz++) { // Find max and min material number @@ -1022,7 +891,7 @@ void AliRun::MediaTable() for(i=0;i<(fNdets-1)/6+1;i++) { for(k=0;k< (6(dets[ind]); if(det) printf(" %6s: %3d -> %3d;",det->GetName(),det->LoMedium(), det->HiMedium()); @@ -1033,7 +902,7 @@ void AliRun::MediaTable() } } -//____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetGenerator(AliGenerator *generator) { // @@ -1042,7 +911,7 @@ void AliRun::SetGenerator(AliGenerator *generator) if(!fGenerator) fGenerator = generator; } -//____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ResetGenerator(AliGenerator *generator) { // @@ -1058,19 +927,22 @@ void AliRun::ResetGenerator(AliGenerator *generator) fGenerator = generator; } -//____________________________________________________________________________ -void AliRun::SetTransPar(char *filename) +//_______________________________________________________________________ +void AliRun::SetTransPar(const char *filename) { + // + // Sets the file name for transport parameters + // fTransParName = filename; } -//____________________________________________________________________________ -void AliRun::SetBaseFile(char *filename) +//_______________________________________________________________________ +void AliRun::SetBaseFile(const char *filename) { fBaseFileName = filename; } -//____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ReadTransPar() { // @@ -1181,7 +1053,7 @@ void AliRun::ReadTransPar() } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::MakeTree(Option_t *option, const char *file) { // @@ -1212,7 +1084,7 @@ void AliRun::MakeTree(Option_t *option, const char *file) // branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0); branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0); branch->SetAutoDelete(kFALSE); - TFolder *folder = (TFolder *)gROOT->FindObjectAny("/Folders/RunMC/Event/Header"); + TFolder *folder = dynamic_cast(gROOT->FindObjectAny("/Folders/RunMC/Event/Header")); if (folder) folder->Add(fHeader); // branch = fTreeE->Branch("Stack","AliStack", &fStack, 4000, 0); // branch->SetAutoDelete(kFALSE); @@ -1225,7 +1097,7 @@ void AliRun::MakeTree(Option_t *option, const char *file) sprintf(outFile,"%s/%s",GetBaseFile(),file); branch->SetFile(outFile); TIter next( branch->GetListOfBranches()); - while ((branch=(TBranch*)next())) { + while ((branch=dynamic_cast(next()))) { branch->SetFile(outFile); } if (GetDebug()>1) @@ -1270,19 +1142,22 @@ void AliRun::MakeTree(Option_t *option, const char *file) // will be in turn a subbranch of the detector master branch TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { if (oH) detector->MakeBranch(option,file); if (oTR) detector->MakeBranchTR(option,file); } } -//_____________________________________________________________________________ -TParticle* AliRun::Particle(Int_t i) +//_______________________________________________________________________ +TParticle* AliRun::Particle(Int_t i) const { - return fStack->Particle(i); + // + // Returns particle i on the simulation stack + // + return fStack->Particle(i); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ResetDigits() { // @@ -1290,12 +1165,12 @@ void AliRun::ResetDigits() // TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->ResetDigits(); } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ResetSDigits() { // @@ -1303,12 +1178,12 @@ void AliRun::ResetSDigits() // TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->ResetSDigits(); } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ResetHits() { // @@ -1316,12 +1191,12 @@ void AliRun::ResetHits() // TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->ResetHits(); } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ResetTrackReferences() { // @@ -1329,12 +1204,12 @@ void AliRun::ResetTrackReferences() // TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->ResetTrackReferences(); } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ResetPoints() { // @@ -1342,18 +1217,20 @@ void AliRun::ResetPoints() // TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->ResetPoints(); } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::InitMC(const char *setup) { // // Initialize the Alice setup // + Announce(); + if(fInitDone) { Warning("Init","Cannot initialise AliRun twice!\n"); return; @@ -1367,6 +1244,7 @@ void AliRun::InitMC(const char *setup) gMC->SetStack(fStack); gMC->DefineParticles(); //Create standard MC particles + AliPDG::AddParticlesToPdgDataBase(); TObject *objfirst, *objlast; @@ -1381,7 +1259,7 @@ void AliRun::InitMC(const char *setup) TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->SetTreeAddress(); objlast = gDirectory->GetList()->Last(); @@ -1418,7 +1296,7 @@ void AliRun::InitMC(const char *setup) Write(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::RunMC(Int_t nevent, const char *setup) { // @@ -1449,7 +1327,7 @@ void AliRun::RunMC(Int_t nevent, const char *setup) if(nevent>0) FinishRun(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::RunReco(const char *selected, Int_t first, Int_t last) { // @@ -1457,7 +1335,7 @@ void AliRun::RunReco(const char *selected, Int_t first, Int_t last) // cout << "Found "<< gAlice->TreeE()->GetEntries() << "events" << endl; Int_t nFirst = first; - Int_t nLast = (last < 0)? (Int_t) gAlice->TreeE()->GetEntries() : last; + Int_t nLast = (last < 0)? static_cast(gAlice->TreeE()->GetEntries()) : last; for (Int_t nevent = nFirst; nevent <= nLast; nevent++) { cout << "Processing event "<< nevent << endl; @@ -1467,7 +1345,7 @@ void AliRun::RunReco(const char *selected, Int_t first, Int_t last) } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Hits2Digits(const char *selected) { @@ -1483,7 +1361,7 @@ void AliRun::Hits2Digits(const char *selected) } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Tree2Tree(Option_t *option, const char *selected) { @@ -1511,51 +1389,54 @@ void AliRun::Tree2Tree(Option_t *option, const char *selected) TDirectory *cwd = gDirectory; + TObject *obj; + char outFile[32]; - while((detector = (AliDetector*)next())) { + while((obj = next())) { + if (!dynamic_cast(obj)) + Fatal("Tree2Tree","Wrong type in fModules array\n"); + if (!(detector = dynamic_cast(obj))) continue; if (selected) if (strcmp(detector->GetName(),selected)) continue; - if (detector->IsActive()){ - if (gSystem->Getenv("CONFIG_SPLIT_FILE")) { - if (oS) { - sprintf(outFile,"SDigits.%s.root",detector->GetName()); - detector->MakeBranch("S",outFile); - } - if (oD) { - sprintf(outFile,"Digits.%s.root",detector->GetName()); - detector->MakeBranch("D",outFile); - } - if (oR) { - sprintf(outFile,"Reco.%s.root",detector->GetName()); - detector->MakeBranch("R",outFile); - } - } else { - detector->MakeBranch(option); - } - - cwd->cd(); - + if (!detector->IsActive()) continue; + if (gSystem->Getenv("CONFIG_SPLIT_FILE")) { if (oS) { - cout << "Hits2SDigits: Processing " << detector->GetName() << "..." << endl; - detector->Hits2SDigits(); - } + sprintf(outFile,"SDigits.%s.root",detector->GetName()); + detector->MakeBranch("S",outFile); + } if (oD) { - cout << "SDigits2Digits: Processing " << detector->GetName() << "..." << endl; - detector->SDigits2Digits(); - } + sprintf(outFile,"Digits.%s.root",detector->GetName()); + detector->MakeBranch("D",outFile); + } if (oR) { - cout << "Digits2Reco: Processing " << detector->GetName() << "..." << endl; - detector->Digits2Reco(); - } - - cwd->cd(); - } - } -} - - -//_____________________________________________________________________________ + sprintf(outFile,"Reco.%s.root",detector->GetName()); + detector->MakeBranch("R",outFile); + } + } else { + detector->MakeBranch(option); + } + + cwd->cd(); + + if (oS) { + cout << "Hits2SDigits: Processing " << detector->GetName() << "..." << endl; + detector->Hits2SDigits(); + } + if (oD) { + cout << "SDigits2Digits: Processing " << detector->GetName() << "..." << endl; + detector->SDigits2Digits(); + } + if (oR) { + cout << "Digits2Reco: Processing " << detector->GetName() << "..." << endl; + detector->Digits2Reco(); + } + + cwd->cd(); + } +} + +//_______________________________________________________________________ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min, Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max, Float_t rmin,Float_t rmax,Float_t zmax, AliLegoGenerator* gener) @@ -1636,7 +1517,7 @@ void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min, delete fLego; fLego=0; } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetConfigFunction(const char * config) { // @@ -1646,7 +1527,7 @@ void AliRun::SetConfigFunction(const char * config) fConfigFunction=config; } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetCurrentTrack(Int_t track) { // @@ -1655,10 +1536,10 @@ void AliRun::SetCurrentTrack(Int_t track) fStack->SetCurrentTrack(track); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom, Float_t *vpos, Float_t *polar, Float_t tof, - AliMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) + TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) { // Delegate to stack // @@ -1667,12 +1548,12 @@ void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom, mech, ntr, weight, is); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, Double_t px, Double_t py, Double_t pz, Double_t e, Double_t vx, Double_t vy, Double_t vz, Double_t tof, Double_t polx, Double_t poly, Double_t polz, - AliMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) + TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is) { // Delegate to stack // @@ -1681,7 +1562,7 @@ void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg, } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetHighWaterMark(const Int_t nt) { // @@ -1689,7 +1570,7 @@ void AliRun::SetHighWaterMark(const Int_t nt) fStack->SetHighWaterMark(nt); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::KeepTrack(const Int_t track) { // @@ -1702,7 +1583,7 @@ void AliRun::KeepTrack(const Int_t track) // MC Application // -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::ConstructGeometry() { // @@ -1713,7 +1594,7 @@ void AliRun::ConstructGeometry() TIter next(fModules); AliModule *detector; printf("Geometry creation:\n"); - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { stw.Start(); // Initialise detector materials and geometry detector->CreateMaterials(); @@ -1723,7 +1604,7 @@ void AliRun::ConstructGeometry() } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::InitGeometry() { // @@ -1734,7 +1615,7 @@ void AliRun::InitGeometry() TStopwatch stw; TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { stw.Start(); // Initialise detector and display geometry detector->Init(); @@ -1745,7 +1626,7 @@ void AliRun::InitGeometry() } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::GeneratePrimaries() { // @@ -1755,7 +1636,7 @@ void AliRun::GeneratePrimaries() Generator()->Generate(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::BeginEvent() { // Clean-up previous event @@ -1823,7 +1704,7 @@ void AliRun::BeginEvent() } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::BeginPrimary() { // @@ -1836,20 +1717,23 @@ void AliRun::BeginPrimary() } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::PreTrack() { - TObjArray &dets = *fModules; - AliModule *module; - - for(Int_t i=0; i<=fNdets; i++) - if((module = (AliModule*)dets[i])) - module->PreTrack(); - - fMCQA->PreTrack(); + // + // Method called before each track + // + TObjArray &dets = *fModules; + AliModule *module; + + for(Int_t i=0; i<=fNdets; i++) + if((module = dynamic_cast(dets[i]))) + module->PreTrack(); + + fMCQA->PreTrack(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Stepping() { // @@ -1869,7 +1753,7 @@ void AliRun::Stepping() AddEnergyDeposit(gMC->CurrentVolID(copy),gMC->Edep()); //Call the appropriate stepping routine; - AliModule *det = (AliModule*)fModules->At(id); + AliModule *det = dynamic_cast(fModules->At(id)); if(det && det->StepManagerIsEnabled()) { fMCQA->StepManager(id); det->StepManager(); @@ -1877,18 +1761,21 @@ void AliRun::Stepping() } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::PostTrack() { - TObjArray &dets = *fModules; - AliModule *module; - - for(Int_t i=0; i<=fNdets; i++) - if((module = (AliModule*)dets[i])) - module->PostTrack(); + // + // Called after a track has been trasported + // + TObjArray &dets = *fModules; + AliModule *module; + + for(Int_t i=0; i<=fNdets; i++) + if((module = dynamic_cast(dets[i]))) + module->PostTrack(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::FinishPrimary() { // @@ -1902,7 +1789,7 @@ void AliRun::FinishPrimary() TIter next(fModules); AliModule *detector; - while((detector = (AliModule*)next())) { + while((detector = dynamic_cast(next()))) { detector->FinishPrimary(); } @@ -1920,7 +1807,7 @@ void AliRun::FinishPrimary() // if(++count%times==1) gObjectTable->Print(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::FinishEvent() { // @@ -1965,21 +1852,25 @@ void AliRun::FinishEvent() ++fEventNrInRun; } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Field(const Double_t* x, Double_t *b) const { - 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]; - } - else { - printf("No mag field defined!\n"); - b[0]=b[1]=b[2]=0.; - } + // + // Returns the magnetic field at point x[3] + // Units are kGauss + // + 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]; + } + else { + printf("No mag field defined!\n"); + b[0]=b[1]=b[2]=0.; + } } @@ -1987,7 +1878,7 @@ void AliRun::Field(const Double_t* x, Double_t *b) const // End of MC Application // -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliRun::Streamer(TBuffer &R__b) { // Stream an object of class AliRun. @@ -1999,7 +1890,7 @@ void AliRun::Streamer(TBuffer &R__b) // gROOT->GetListOfBrowsables()->Add(this,"Run"); - fTreeE = (TTree*)gDirectory->Get("TE"); + fTreeE = dynamic_cast(gDirectory->Get("TE")); if (fTreeE) { fTreeE->SetBranchAddress("Header", &fHeader); } @@ -2013,7 +1904,7 @@ void AliRun::Streamer(TBuffer &R__b) } -//___________________________________________________________________________ +//_______________________________________________________________________ Int_t AliRun::CurrentTrack() const { // // Returns current track @@ -2021,7 +1912,7 @@ Int_t AliRun::CurrentTrack() const { return fStack->CurrentTrack(); } -//___________________________________________________________________________ +//_______________________________________________________________________ Int_t AliRun::GetNtrack() const { // // Returns number of tracks in stack @@ -2029,16 +1920,16 @@ Int_t AliRun::GetNtrack() const { return fStack->GetNtrack(); } -//___________________________________________________________________________ -TObjArray* AliRun::Particles() { +//_______________________________________________________________________ +TObjArray* AliRun::Particles() const { // // Returns pointer to Particles array // return fStack->Particles(); } -//___________________________________________________________________________ -TTree* AliRun::TreeK() { +//_______________________________________________________________________ +TTree* AliRun::TreeK() const { // // Returns pointer to the TreeK array // @@ -2046,13 +1937,13 @@ TTree* AliRun::TreeK() { } -//___________________________________________________________________________ +//_______________________________________________________________________ void AliRun::SetGenEventHeader(AliGenEventHeader* header) { fHeader->SetGenEventHeader(header); } -//___________________________________________________________________________ +//_______________________________________________________________________ TFile* AliRun::InitFile(TString fileName) { // @@ -2068,7 +1959,7 @@ TFile* AliRun::InitFile(TString fileName) return file; } -//___________________________________________________________________________ +//_______________________________________________________________________ TFile* AliRun::InitTreeFile(Option_t *option, TString fileName) { // @@ -2188,10 +2079,10 @@ TFile* AliRun::InitTreeFile(Option_t *option, TString fileName) } return ptr; } - + return 0; } -//___________________________________________________________________________ +//_______________________________________________________________________ void AliRun::PrintTreeFile() { // @@ -2200,7 +2091,7 @@ void AliRun::PrintTreeFile() cout<<"===================================================\n"; TFile *file = fTreeE->GetCurrentFile(); TString curfilname=""; - if(file)curfilname=(TString)file->GetName(); + if(file)curfilname=static_cast(file->GetName()); cout<<" Current tree file name: "<