]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliRun.cxx
Corrected deletion of gMC (I.Hrivnacova)
[u/mrichter/AliRoot.git] / STEER / AliRun.cxx
index 56160612a304a4593117dcc479836e35ab52b523..9a88b014bd3f9d181b8afa9a5f9715eea62a2779 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.92  2002/11/15 17:12:04  alibrary
-Cleaning includes
-
-Revision 1.91  2002/10/29 14:26:49  hristov
-Code clean-up (F.Carminati)
-
-Revision 1.90  2002/10/22 15:02:15  alibrary
-Introducing Riostream.h
-
-Revision 1.89  2002/10/17 16:26:39  hristov
-Definition of additional particles moved to VMC (I.Hrivnacova)
-
-Revision 1.88  2002/10/14 14:57:32  hristov
-Merging the VirtualMC branch to the main development branch (HEAD)
-
-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$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -279,9 +51,7 @@ Introduction of the Copyright and cvs Log
 #include "TFile.h"
 #include "TFolder.h"
 #include "TGeometry.h"
-#include "TKey.h"
 #include "TNode.h"
-#include "TObjectTable.h"
 #include "TParticle.h"
 #include "TRandom3.h"
 #include "TROOT.h"
@@ -291,10 +61,8 @@ Introduction of the Copyright and cvs Log
 #include "AliConfig.h"
 #include "AliDetector.h"
 #include "AliDisplay.h"
-#include "AliGenEventHeader.h"
 #include "AliGenerator.h"
 #include "AliHeader.h"
-#include "AliHit.h"
 #include "AliLego.h"
 #include "AliLegoGenerator.h"
 #include "AliMCQA.h"
@@ -503,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;
@@ -552,6 +321,9 @@ AliRun::~AliRun()
 //_______________________________________________________________________
 void AliRun::Copy(AliRun &) const
 {
+  //
+  //  Copy method ... not implemented
+  //
   Fatal("Copy","Not implemented!\n");
 }
 
@@ -640,7 +412,7 @@ void AliRun::CleanDetectors()
 }
 
 //_______________________________________________________________________
-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
@@ -833,6 +605,27 @@ 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
 {
@@ -1137,6 +930,9 @@ void AliRun::ResetGenerator(AliGenerator *generator)
 //_______________________________________________________________________
 void AliRun::SetTransPar(const char *filename)
 {
+  //
+  // Sets the file name for transport parameters
+  //
   fTransParName = filename;
 }
 
@@ -1353,9 +1149,12 @@ void AliRun::MakeTree(Option_t *option, const char *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);
 }
 
 //_______________________________________________________________________
@@ -1430,6 +1229,8 @@ void AliRun::InitMC(const char *setup)
   // Initialize the Alice setup
   //
 
+  Announce();
+
   if(fInitDone) {
     Warning("Init","Cannot initialise AliRun twice!\n");
     return;
@@ -1588,50 +1389,53 @@ void AliRun::Tree2Tree(Option_t *option, const char *selected)
 
    TDirectory *cwd = gDirectory;
 
+   TObject *obj;
+
    char outFile[32];
    
-   while((detector = dynamic_cast<AliDetector*>(next()))) {
+   while((obj = next())) {
+     if (!dynamic_cast<AliModule*>(obj)) 
+       Fatal("Tree2Tree","Wrong type in fModules array\n");
+     if (!(detector = dynamic_cast<AliDetector*>(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,
@@ -1916,14 +1720,17 @@ void AliRun::BeginPrimary()
 //_______________________________________________________________________
 void AliRun::PreTrack()
 {
-     TObjArray &dets = *fModules;
-     AliModule *module;
-
-     for(Int_t i=0; i<=fNdets; i++)
-       if((module = dynamic_cast<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<AliModule*>(dets[i])))
+      module->PreTrack();
+  
+  fMCQA->PreTrack();
 }
 
 //_______________________________________________________________________
@@ -1957,12 +1764,15 @@ void AliRun::Stepping()
 //_______________________________________________________________________
 void AliRun::PostTrack()
 {
-     TObjArray &dets = *fModules;
-     AliModule *module;
-
-     for(Int_t i=0; i<=fNdets; i++)
-       if((module = dynamic_cast<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<AliModule*>(dets[i])))
+      module->PostTrack();
 }
 
 //_______________________________________________________________________
@@ -2045,18 +1855,22 @@ void AliRun::FinishEvent()
 //_______________________________________________________________________
 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.;
+  }
 
 }      
 
@@ -2107,7 +1921,7 @@ Int_t AliRun::GetNtrack() const {
 }
 
 //_______________________________________________________________________
-TObjArray* AliRun::Particles() {
+TObjArray* AliRun::Particles() const {
   //
   // Returns pointer to Particles array
   //
@@ -2115,7 +1929,7 @@ TObjArray* AliRun::Particles() {
 }
 
 //_______________________________________________________________________
-TTree* AliRun::TreeK() {
+TTree* AliRun::TreeK() const {
   //
   // Returns pointer to the TreeK array
   //