/*
$Log$
+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
// //
///////////////////////////////////////////////////////////////////////////////
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <iostream.h>
+
#include <TFile.h>
#include <TRandom.h>
#include <TBRIK.h>
#include <TCint.h>
#include <TSystem.h>
#include <TObjectTable.h>
+#include <TTree.h>
+#include <TGeometry.h>
+#include <TROOT.h>
+#include <TBrowser.h>
+#include <TFolder.h>
#include "TParticle.h"
#include "AliRun.h"
#include "AliDisplay.h"
#include "AliMC.h"
#include "AliLego.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 "AliStack.h"
+#include "AliGenEventHeader.h"
+#include "AliHeader.h"
+
+#include "AliDetector.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
AliRun *gAlice;
-static AliHeader *header;
-
ClassImp(AliRun)
//_____________________________________________________________________________
//
// Default constructor for AliRun
//
- header=&fHeader;
+ fHeader = 0;
fRun = 0;
fEvent = 0;
- fCurrent = -1;
- fModules = 0;
+ fStack = 0;
+ fModules = 0;
fGenerator = 0;
fTreeD = 0;
- fTreeK = 0;
fTreeH = 0;
fTreeE = 0;
fTreeR = 0;
- fParticles = 0;
+ fTreeS = 0;
fGeometry = 0;
fDisplay = 0;
fField = 0;
- fMC = 0;
+ fMC = 0;
fNdets = 0;
fImedia = 0;
fTrRmax = 1.e10;
fPDGDB = 0; //Particle factory object!
fHitLists = 0;
fConfigFunction = "\0";
+ fRandom = 0;
+ fMCQA = 0;
+ fTransParName = "\0";
+ fBaseFileName = ".\0";
+ fDebug = 0;
}
//_____________________________________________________________________________
gAlice = this;
fTreeD = 0;
- fTreeK = 0;
fTreeH = 0;
fTreeE = 0;
fTreeR = 0;
+ fTreeS = 0;
fTrRmax = 1.e10;
fTrZmax = 1.e10;
fGenerator = 0;
fLego = 0;
fField = 0;
fConfigFunction = "Config();";
+
+ // Set random number generator
+ gRandom = fRandom = new TRandom3();
+
+ if (gSystem->Getenv("CONFIG_SEED")) {
+ gRandom->SetSeed((UInt_t)atoi(gSystem->Getenv("CONFIG_SEED")));
+ }
gROOT->GetListOfBrowsables()->Add(this,name);
//
+ // Particle stack
+ fStack = new AliStack(10000);
// create the support list for the various Detectors
fModules = new TObjArray(77);
//
BuildSimpleGeometry();
-
- fNtrack=0;
- fHgwmk=0;
- fCurrent=-1;
- header=&fHeader;
+ fHeader = new AliHeader();
fRun = 0;
fEvent = 0;
//
- // Create the particle stack
- fParticles = new TClonesArray("TParticle",100);
-
fDisplay = 0;
//
// Create default mag field
//
// Make particles
fPDGDB = TDatabasePDG::Instance(); //Particle factory object!
+
+ AliConfig::Instance()->Add(fPDGDB);
//
// Create HitLists list
fHitLists = new TList();
+ //
+ SetTransPar();
+ fBaseFileName = ".\0";
+ //
+ fDebug = 0;
}
+
//_____________________________________________________________________________
AliRun::~AliRun()
{
//
- // Defaullt AliRun destructor
+ // Default AliRun destructor
//
delete fImedia;
delete fField;
delete fGenerator;
delete fLego;
delete fTreeD;
- delete fTreeK;
delete fTreeH;
delete fTreeE;
delete fTreeR;
+ delete fTreeS;
if (fModules) {
fModules->Delete();
delete fModules;
}
- if (fParticles) {
- fParticles->Delete();
- delete fParticles;
- }
+ delete fStack;
delete fHitLists;
delete fPDGDB;
+ delete fMCQA;
+ delete fHeader;
}
//_____________________________________________________________________________
// of the Root browser.
// It displays the Root Trees and all detectors.
//
- if (fTreeK) b->Add(fTreeK,fTreeK->GetName());
+ if(!fStack) fStack=fHeader->Stack();
+ TTree* pTreeK = fStack->TreeK();
+
+ if (pTreeK) b->Add(pTreeK,pTreeK->GetName());
if (fTreeH) b->Add(fTreeH,fTreeH->GetName());
if (fTreeD) b->Add(fTreeD,fTreeD->GetName());
if (fTreeE) b->Add(fTreeE,fTreeE->GetName());
if (fTreeR) b->Add(fTreeR,fTreeR->GetName());
+ if (fTreeS) b->Add(fTreeS,fTreeS->GetName());
TIter next(fModules);
AliModule *detector;
while((detector = (AliModule*)next())) {
b->Add(detector,detector->GetName());
}
+ b->Add(fMCQA,"AliMCQA");
}
//_____________________________________________________________________________
}
}
-//_____________________________________________________________________________
-void AliRun::CleanParents()
-{
- //
- // Clean Particles stack.
- // Set parent/daughter relations
- //
- TClonesArray &particles = *(gAlice->Particles());
- TParticle *part;
- int i;
- for(i=0; i<fNtrack; i++) {
- part = (TParticle *)particles.UncheckedAt(i);
- if(!part->TestBit(Daughters_Bit)) {
- part->SetFirstDaughter(-1);
- part->SetLastDaughter(-1);
- }
- }
-}
-
//_____________________________________________________________________________
Int_t AliRun::DistancetoPrimitive(Int_t, Int_t)
{
}
//_____________________________________________________________________________
-void AliRun::DumpPart (Int_t i)
+void AliRun::DumpPart (Int_t i) const
{
//
// Dumps particle i in the stack
//
- TClonesArray &particles = *fParticles;
- ((TParticle*) particles[i])->Print();
+ fStack->DumpPart(i);
}
//_____________________________________________________________________________
-void AliRun::DumpPStack ()
+void AliRun::DumpPStack () const
{
//
// Dumps the particle stack
//
- TClonesArray &particles = *fParticles;
- printf(
- "\n\n=======================================================================\n");
- for (Int_t i=0;i<fNtrack;i++)
- {
- printf("-> %d ",i); ((TParticle*) particles[i])->Print();
- printf("--------------------------------------------------------------\n");
- }
- printf(
- "\n=======================================================================\n\n");
+ fStack->DumpPStack();
+}
+
+//_____________________________________________________________________________
+void AliRun::SetField(AliMagF* magField)
+{
+ // Set Magnetic Field Map
+ fField = magField;
+ fField->ReadField();
}
//_____________________________________________________________________________
//
// --- Sanity check on mag field flags
- if(type<0 || type > 2) {
- Warning("SetField",
- "Invalid magnetic field flag: %5d; Helix tracking chosen instead\n"
- ,type);
- type=2;
- }
if(fField) delete fField;
if(version==1) {
- fField = new AliMagFC("Map1"," ",type,version,scale,maxField);
- } else if(version<=3) {
- fField = new AliMagFCM("Map2-3",filename,type,version,scale,maxField);
+ fField = new AliMagFC("Map1"," ",type,scale,maxField);
+ } else if(version<=2) {
+ fField = new AliMagFCM("Map2-3",filename,type,scale,maxField);
+ fField->ReadField();
+ } else if(version==3) {
+ fField = new AliMagFDM("Map4",filename,type,scale,maxField);
fField->ReadField();
} else {
Warning("SetField","Invalid map %d\n",version);
}
}
+
+//_____________________________________________________________________________
+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();
+}
//_____________________________________________________________________________
-void AliRun::FillTree()
+void AliRun::PostTrack()
{
- //
- // Fills all AliRun TTrees
- //
- if (fTreeK) fTreeK->Fill();
- if (fTreeH) fTreeH->Fill();
- if (fTreeD) fTreeD->Fill();
- if (fTreeR) fTreeR->Fill();
+ TObjArray &dets = *fModules;
+ AliModule *module;
+
+ for(Int_t i=0; i<=fNdets; i++)
+ if((module = (AliModule*)dets[i]))
+ module->PostTrack();
}
-
+
//_____________________________________________________________________________
void AliRun::FinishPrimary()
{
// static Int_t count=0;
// const Int_t times=10;
// This primary is finished, purify stack
- PurifyKine();
+ fStack->PurifyKine();
+
+ TIter next(fModules);
+ AliModule *detector;
+ while((detector = (AliModule*)next())) {
+ detector->FinishPrimary();
+ }
// Write out hits if any
if (gAlice->TreeH()) {
gAlice->TreeH()->Fill();
}
+ //
+ // if(++count%times==1) gObjectTable->Print();
+}
+
+//_____________________________________________________________________________
+void AliRun::BeginPrimary()
+{
+ //
+ // Called at the beginning of each primary track
+ //
+
// Reset Hits info
gAlice->ResetHits();
- //
- // if(++count%times==1) gObjectTable->Print();
}
//_____________________________________________________________________________
fSummEnergy[i]+=fEventEnergy[i];
fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
}
- fEventEnergy.Reset();
+
+
- // Clean detector information
- CleanDetectors();
+ // Update Header information
+
+ fHeader->SetNprimary(fStack->GetNprimary());
+ fHeader->SetNtrack(fStack->GetNtrack());
+
// Write out the kinematics
- if (fTreeK) {
- CleanParents();
- fTreeK->Fill();
- }
-
- // Write out the digits
- if (fTreeD) {
- fTreeD->Fill();
- ResetDigits();
- }
-
- // Write out reconstructed clusters
- if (fTreeR) {
- fTreeR->Fill();
- }
-
+ fStack->FinishEvent();
+
// Write out the event Header information
- if (fTreeE) fTreeE->Fill();
+ if (fTreeE) {
+ fHeader->SetStack(fStack);
+ fTreeE->Fill();
+ }
- // Reset stack info
- ResetStack();
// Write Tree headers
- // Int_t ievent = fHeader.GetEvent();
- // char hname[30];
- // sprintf(hname,"TreeK%d",ievent);
- if (fTreeK) fTreeK->Write();
- // sprintf(hname,"TreeH%d",ievent);
- if (fTreeH) fTreeH->Write();
- // sprintf(hname,"TreeD%d",ievent);
- if (fTreeD) fTreeD->Write();
- // sprintf(hname,"TreeR%d",ievent);
- if (fTreeR) fTreeR->Write();
-
+ TTree* pTreeK = fStack->TreeK();
+ if (pTreeK) pTreeK->Write(0,TObject::kOverwrite);
+ if (fTreeH) fTreeH->Write(0,TObject::kOverwrite);
+
++fEvent;
}
//
if(fLego) fLego->FinishRun();
-
+
// Clean detector information
TIter next(fModules);
AliModule *detector;
//Output energy summary tables
EnergySummary();
+
+ TFile *file = fTreeE->GetCurrentFile();
+
+ file->cd();
- // file is retrieved from whatever tree
- TFile *File = 0;
- if (fTreeK) File = fTreeK->GetCurrentFile();
- if ((!File) && (fTreeH)) File = fTreeH->GetCurrentFile();
- if ((!File) && (fTreeD)) File = fTreeD->GetCurrentFile();
- if ((!File) && (fTreeE)) File = fTreeE->GetCurrentFile();
- if( NULL==File ) {
- Error("FinishRun","There isn't root file!");
- exit(1);
- }
- File->cd();
- fTreeE->Write();
-
- // Clean tree information
- delete fTreeK; fTreeK = 0;
- delete fTreeH; fTreeH = 0;
- delete fTreeD; fTreeD = 0;
- delete fTreeR; fTreeR = 0;
- delete fTreeE; fTreeE = 0;
+ fTreeE->Write(0,TObject::kOverwrite);
// Write AliRun info and all detectors parameters
- Write();
+ Write(0,TObject::kOverwrite);
+
+ // Clean tree information
+
+ fStack->FinishRun();
+ if (fTreeH) {
+ delete fTreeH; fTreeH = 0;
+ }
+ if (fTreeD) {
+ delete fTreeD; fTreeD = 0;
+ }
+ if (fTreeR) {
+ delete fTreeR; fTreeR = 0;
+ }
+ if (fTreeE) {
+ delete fTreeE; fTreeE = 0;
+ }
+ if (fTreeS) {
+ delete fTreeS; fTreeS = 0;
+ }
+
// Close output file
- File->Write();
+ file->Write();
}
//_____________________________________________________________________________
void AliRun::FlagTrack(Int_t track)
{
+ // Delegate to stack
//
- // Flags a track and all its family tree to be kept
- //
- int curr;
- TParticle *particle;
-
- curr=track;
- while(1) {
- particle=(TParticle*)fParticles->UncheckedAt(curr);
-
- // If the particle is flagged the three from here upward is saved already
- if(particle->TestBit(Keep_Bit)) return;
-
- // Save this particle
- particle->SetBit(Keep_Bit);
-
- // Move to father if any
- if((curr=particle->GetFirstMother())==-1) return;
- }
+ fStack->FlagTrack(track);
}
//_____________________________________________________________________________
Float_t edtot=0;
Float_t ed, ed2;
Int_t kn, i, left, j, id;
- const Float_t zero=0;
- Int_t ievent=fHeader.GetEvent()+1;
+ const Float_t kzero=0;
+ Int_t ievent=fHeader->GetEvent()+1;
//
// Energy loss information
if(ievent) {
ed=ed/ievent;
ed2=fSum2Energy[kn];
ed2=ed2/ievent;
- ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,zero))/ed;
+ ed2=100*TMath::Sqrt(TMath::Max(ed2-ed*ed,kzero))/ed;
} else
ed2=99;
fSummEnergy[ndep]=ed;
- fSum2Energy[ndep]=TMath::Min((Float_t) 99.,TMath::Max(ed2,zero));
+ fSum2Energy[ndep]=TMath::Min((Float_t) 99.,TMath::Max(ed2,kzero));
edtot+=ed;
ndep++;
}
}
//_____________________________________________________________________________
-AliModule *AliRun::GetModule(const char *name)
+AliModule *AliRun::GetModule(const char *name) const
{
//
// Return pointer to detector from name
}
//_____________________________________________________________________________
-AliDetector *AliRun::GetDetector(const char *name)
+AliDetector *AliRun::GetDetector(const char *name) const
{
//
// Return pointer to detector from name
}
//_____________________________________________________________________________
-Int_t AliRun::GetModuleID(const char *name)
+Int_t AliRun::GetModuleID(const char *name) const
{
//
// Return galice internal detector identifier from name
//
// Reset existing structures
- ResetStack();
ResetHits();
ResetDigits();
+ ResetSDigits();
// Delete Trees already connected
- if (fTreeK) delete fTreeK;
if (fTreeH) delete fTreeH;
if (fTreeD) delete fTreeD;
if (fTreeR) delete fTreeR;
+ if (fTreeS) delete fTreeS;
- // Get header from file
- if(fTreeE) fTreeE->GetEntry(event);
- else Error("GetEvent","Cannot file Header Tree\n");
+ // Create the particle stack
+ if (fHeader) delete fHeader;
+ fHeader = 0;
- // Get Kine Tree from file
+ // Get header from file
+ if(fTreeE) {
+ fTreeE->SetBranchAddress("Header", &fHeader);
+ fTreeE->GetEntry(event);
+ }
+ else
+ Error("GetEvent","Cannot find Header Tree (TE)\n");
+
+ // Get the stack from the header
+ if (fStack) delete fStack;
+ fStack = fHeader->Stack();
+ fStack->GetEvent(event);
+ //
+ TFile *file = fTreeE->GetCurrentFile();
char treeName[20];
- sprintf(treeName,"TreeK%d",event);
- fTreeK = (TTree*)gDirectory->Get(treeName);
- if (fTreeK) fTreeK->SetBranchAddress("Particles", &fParticles);
- else Error("GetEvent","cannot find Kine Tree for event:%d\n",event);
-
+ file->cd();
+
// Get Hits Tree header from file
sprintf(treeName,"TreeH%d",event);
fTreeH = (TTree*)gDirectory->Get(treeName);
sprintf(treeName,"TreeD%d",event);
fTreeD = (TTree*)gDirectory->Get(treeName);
if (!fTreeD) {
- Warning("GetEvent","cannot find Digits Tree for event:%d\n",event);
+ // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event);
}
-
+
+ file->cd();
+
+ // Get SDigits Tree header from file
+ sprintf(treeName,"TreeS%d",event);
+ fTreeS = (TTree*)gDirectory->Get(treeName);
+ if (!fTreeS) {
+ // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event);
+ }
+
+ file->cd();
// Get Reconstruct Tree header from file
sprintf(treeName,"TreeR%d",event);
if (!fTreeR) {
// printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event);
}
+
+ file->cd();
// Set Trees branch addresses
TIter next(fModules);
while((detector = (AliModule*)next())) {
detector->SetTreeAddress();
}
-
- if (fTreeK) fTreeK->GetEvent(0);
- fNtrack = Int_t (fParticles->GetEntries());
- return fNtrack;
+
+ return fStack->GetNtrack();
}
//_____________________________________________________________________________
TIter next(fModules);
AliModule *detector;
while((detector = (AliModule*)next())) {
- detector->SetTreeAddress();
TList *dnodes=detector->Nodes();
Int_t j;
TNode *node, *node1;
Float_t &e, Float_t *vpos, Float_t *polar,
Float_t &tof)
{
+ // Delegate to stack
//
- // Return next track from stack of particles
- //
- TVector3 pol;
- fCurrent=-1;
- TParticle *track;
- for(Int_t i=fNtrack-1; i>=0; i--) {
- track=(TParticle*) fParticles->UncheckedAt(i);
- if(!track->TestBit(Done_Bit)) {
- //
- // The track has not yet been processed
- fCurrent=i;
- ipart=track->GetPdgCode();
- pmom[0]=track->Px();
- pmom[1]=track->Py();
- pmom[2]=track->Pz();
- e =track->Energy();
- vpos[0]=track->Vx();
- vpos[1]=track->Vy();
- vpos[2]=track->Vz();
- track->GetPolarisation(pol);
- polar[0]=pol.X();
- polar[1]=pol.Y();
- polar[2]=pol.Z();
- tof=track->T();
- track->SetBit(Done_Bit);
- break;
- }
- }
- mtrack=fCurrent;
- //
- // stop and start timer when we start a primary track
- Int_t nprimaries = fHeader.GetNprimary();
- if (fCurrent >= nprimaries) return;
- if (fCurrent < nprimaries-1) {
- fTimer.Stop();
- track=(TParticle*) fParticles->UncheckedAt(fCurrent+1);
- // track->SetProcessTime(fTimer.CpuTime());
- }
- fTimer.Start();
+ fStack->GetNextTrack(mtrack, ipart, pmom, e, vpos, polar, tof);
}
//_____________________________________________________________________________
-Int_t AliRun::GetPrimary(Int_t track)
+Int_t AliRun::GetPrimary(Int_t track) const
{
//
// return number of primary that has generated track
//
- int current, parent;
- TParticle *part;
- //
- parent=track;
- while (1) {
- current=parent;
- part = (TParticle *)fParticles->UncheckedAt(current);
- parent=part->GetFirstMother();
- if(parent<0) return current;
- }
+ return fStack->GetPrimary(track);
}
//_____________________________________________________________________________
// Initialize the Alice setup
//
+ if(fInitDone) {
+ Warning("Init","Cannot initialise AliRun twice!\n");
+ return;
+ }
+
gROOT->LoadMacro(setup);
gInterpreter->ProcessLine(fConfigFunction.Data());
+
gMC->DefineParticles(); //Create standard MC particles
TObject *objfirst, *objlast;
//=================Create Materials and geometry
gMC->Init();
+ // Added also after in case of interactive initialisation of modules
+ fNdets = fModules->GetLast()+1;
+
TIter next(fModules);
AliModule *detector;
while((detector = (AliModule*)next())) {
objfirst = gDirectory->GetList()->After(objfirst);
}
}
- SetTransPar(); //Read the cuts for all materials
+ ReadTransPar(); //Read the cuts for all materials
MediaTable(); //Build the special IMEDIA table
fGeometry->Write();
fInitDone = kTRUE;
+
+ fMCQA = new AliMCQA(fNdets);
+
+ AliConfig::Instance();
+ //
+ // Save stuff at the beginning of the file to avoid file corruption
+ Write();
}
//_____________________________________________________________________________
}
//____________________________________________________________________________
-void AliRun::SetTransPar(char* filename)
+void AliRun::SetTransPar(char *filename)
+{
+ fTransParName = filename;
+}
+
+//____________________________________________________________________________
+void AliRun::SetBaseFile(char *filename)
+{
+ fBaseFileName = filename;
+}
+
+//____________________________________________________________________________
+void AliRun::ReadTransPar()
{
//
// Read filename to set the transport parameters
//
- const Int_t ncuts=10;
- const Int_t nflags=11;
- const Int_t npars=ncuts+nflags;
- const char pars[npars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
+ const Int_t kncuts=10;
+ const Int_t knflags=11;
+ const Int_t knpars=kncuts+knflags;
+ const char kpars[knpars][7] = {"CUTGAM" ,"CUTELE","CUTNEU","CUTHAD","CUTMUO",
"BCUTE","BCUTM","DCUTE","DCUTM","PPCUTM","ANNI",
"BREM","COMP","DCAY","DRAY","HADR","LOSS",
"MULS","PAIR","PHOT","RAYL"};
char line[256];
char detName[7];
char* filtmp;
- Float_t cut[ncuts];
- Int_t flag[nflags];
+ Float_t cut[kncuts];
+ Int_t flag[knflags];
Int_t i, itmed, iret, ktmed, kz;
FILE *lun;
//
// See whether the file is there
- filtmp=gSystem->ExpandPathName(filename);
+ filtmp=gSystem->ExpandPathName(fTransParName.Data());
lun=fopen(filtmp,"r");
delete [] filtmp;
if(!lun) {
- Warning("SetTransPar","File %s does not exist!\n",filename);
+ Warning("ReadTransPar","File %s does not exist!\n",fTransParName.Data());
return;
}
//
- printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
- printf(" *%59s\n","*");
- printf(" * Please check carefully what you are doing!%10s\n","*");
- printf(" *%59s\n","*");
+ if(fDebug) {
+ printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
+ printf(" *%59s\n","*");
+ printf(" * Please check carefully what you are doing!%10s\n","*");
+ printf(" *%59s\n","*");
+ }
//
while(1) {
// Initialise cuts and flags
- for(i=0;i<ncuts;i++) cut[i]=-99;
- for(i=0;i<nflags;i++) flag[i]=-99;
+ for(i=0;i<kncuts;i++) cut[i]=-99;
+ for(i=0;i<knflags;i++) flag[i]=-99;
itmed=0;
for(i=0;i<256;i++) line[i]='\0';
// Read up to the end of line excluded
if(iret<0) {
//End of file
fclose(lun);
- printf(" *%59s\n","*");
- printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
+ if(fDebug){
+ printf(" *%59s\n","*");
+ printf(" "); for(i=0;i<60;i++) printf("*"); printf("\n");
+ }
return;
}
// Read the end of line
if(!iret) continue;
if(iret<0) {
//reading error
- Warning("SetTransPar","Error reading file %s\n",filename);
+ Warning("ReadTransPar","Error reading file %s\n",fTransParName.Data());
continue;
}
// Check that the module exist
if(0<=itmed && itmed < 100) {
ktmed=idtmed[itmed];
if(!ktmed) {
- Warning("SetTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
+ Warning("ReadTransPar","Invalid tracking medium code %d for %s\n",itmed,mod->GetName());
continue;
}
// Set energy thresholds
- for(kz=0;kz<ncuts;kz++) {
+ for(kz=0;kz<kncuts;kz++) {
if(cut[kz]>=0) {
- printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
- pars[kz],cut[kz],itmed,mod->GetName());
- gMC->Gstpar(ktmed,pars[kz],cut[kz]);
+ if(fDebug) printf(" * %-6s set to %10.3E for tracking medium code %4d for %s\n",
+ kpars[kz],cut[kz],itmed,mod->GetName());
+ gMC->Gstpar(ktmed,kpars[kz],cut[kz]);
}
}
// Set transport mechanisms
- for(kz=0;kz<nflags;kz++) {
+ for(kz=0;kz<knflags;kz++) {
if(flag[kz]>=0) {
- printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
- pars[ncuts+kz],flag[kz],itmed,mod->GetName());
- gMC->Gstpar(ktmed,pars[ncuts+kz],Float_t(flag[kz]));
+ if(fDebug) printf(" * %-6s set to %10d for tracking medium code %4d for %s\n",
+ kpars[kncuts+kz],flag[kz],itmed,mod->GetName());
+ gMC->Gstpar(ktmed,kpars[kncuts+kz],Float_t(flag[kz]));
}
}
} else {
- Warning("SetTransPar","Invalid medium code %d *\n",itmed);
+ Warning("ReadTransPar","Invalid medium code %d *\n",itmed);
continue;
}
} else {
- Warning("SetTransPar","Module %s not present\n",detName);
+ if(fDebug) printf("%s::ReadTransParModule: %s not present\n",ClassName(),detName);
continue;
}
}
}
+
//_____________________________________________________________________________
-void AliRun::MakeTree(Option_t *option)
+void AliRun::MakeTree(Option_t *option, const char *file)
{
//
// Create the ROOT trees
char hname[30];
//
// Analyse options
- char *K = strstr(option,"K");
- char *H = strstr(option,"H");
- char *E = strstr(option,"E");
- char *D = strstr(option,"D");
- char *R = strstr(option,"R");
- //
- if (K && !fTreeK) {
- sprintf(hname,"TreeK%d",fEvent);
- fTreeK = new TTree(hname,"Kinematics");
- // Create a branch for particles
- fTreeK->Branch("Particles",&fParticles,4000);
+ const char *oK = strstr(option,"K");
+ const char *oH = strstr(option,"H");
+ const char *oE = strstr(option,"E");
+ const char *oD = strstr(option,"D");
+ const char *oR = strstr(option,"R");
+ const char *oS = strstr(option,"S");
+ //
+
+ TDirectory *cwd = gDirectory;
+
+ TBranch *branch = 0;
+
+ if (oK) fStack->MakeTree(fEvent, file);
+
+ if (oE && !fTreeE) {
+ fTreeE = new TTree("TE","Header");
+ branch = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0);
+ branch->SetAutoDelete(kFALSE);
+ TFolder *folder = (TFolder *)gROOT->FindObjectAny("/Folders/RunMC/Event/Header");
+ if (folder) folder->Add(fHeader);
+// branch = fTreeE->Branch("Stack","AliStack", &fStack, 4000, 0);
+// branch->SetAutoDelete(kFALSE);
+// if (folder) folder->Add(fStack);
+ fTreeE->Write(0,TObject::kOverwrite);
+ }
+
+ if (file && branch) {
+ char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
+ sprintf(outFile,"%s/%s",GetBaseFile(),file);
+ branch->SetFile(outFile);
+ TIter next( branch->GetListOfBranches());
+ while ((branch=(TBranch*)next())) {
+ branch->SetFile(outFile);
+ }
+ if (GetDebug()>1)
+ printf("* MakeBranch * Diverting Branch %s to file %s\n", branch->GetName(),file);
+ cwd->cd();
+ delete outFile;
}
- if (H && !fTreeH) {
+
+ if (oH && !fTreeH) {
sprintf(hname,"TreeH%d",fEvent);
fTreeH = new TTree(hname,"Hits");
fTreeH->SetAutoSave(1000000000); //no autosave
+ fTreeH->Write(0,TObject::kOverwrite);
}
- if (D && !fTreeD) {
+ if (oD && !fTreeD) {
sprintf(hname,"TreeD%d",fEvent);
fTreeD = new TTree(hname,"Digits");
+ fTreeD->Write(0,TObject::kOverwrite);
+ }
+ if (oS && !fTreeS) {
+ sprintf(hname,"TreeS%d",fEvent);
+ fTreeS = new TTree(hname,"SDigits");
+ fTreeS->Write(0,TObject::kOverwrite);
}
- if (R && !fTreeR) {
+ if (oR && !fTreeR) {
sprintf(hname,"TreeR%d",fEvent);
fTreeR = new TTree(hname,"Reconstruction");
+ fTreeR->Write(0,TObject::kOverwrite);
}
- if (E && !fTreeE) {
- fTreeE = new TTree("TE","Header");
- // Create a branch for Header
- fTreeE->Branch("Header","AliHeader",&header,4000);
- }
+
//
// Create a branch for hits/digits for each detector
// Each branch is a TClonesArray. Each data member of the Hits classes
TIter next(fModules);
AliModule *detector;
while((detector = (AliModule*)next())) {
- if (H || D || R) detector->MakeBranch(option);
+ if (oH) detector->MakeBranch(option,file);
}
}
//_____________________________________________________________________________
-Int_t AliRun::PurifyKine(Int_t lastSavedTrack, Int_t nofTracks)
+TParticle* AliRun::Particle(Int_t i)
{
- //
- // PurifyKine with external parameters
- //
- fHgwmk = lastSavedTrack;
- fNtrack = nofTracks;
- PurifyKine();
- return fHgwmk;
-}
-
-//_____________________________________________________________________________
-void AliRun::PurifyKine()
-{
- //
- // Compress kinematic tree keeping only flagged particles
- // and renaming the particle id's in all the hits
- //
- TClonesArray &particles = *fParticles;
- int nkeep=fHgwmk+1, parent, i;
- TParticle *part, *partnew, *father;
- int *map = new int[particles.GetEntries()];
-
- // Save in Header total number of tracks before compression
- fHeader.SetNtrack(fHeader.GetNtrack()+fNtrack-fHgwmk);
-
- // First pass, invalid Daughter information
- for(i=0; i<fNtrack; i++) {
- // Preset map, to be removed later
- if(i<=fHgwmk) map[i]=i ; else map[i] = -99;
- ((TParticle *)particles.UncheckedAt(i))->ResetBit(Daughters_Bit);
- }
- // Second pass, build map between old and new numbering
- for(i=fHgwmk+1; i<fNtrack; i++) {
- part = (TParticle *)particles.UncheckedAt(i);
- if(part->TestBit(Keep_Bit)) {
-
- // This particle has to be kept
- map[i]=nkeep;
- if(i!=nkeep) {
-
- // Old and new are different, have to copy
- partnew = (TParticle *)particles.UncheckedAt(nkeep);
- // Change due to a bug in the HP compiler
- // *partnew = *part;
- memcpy(partnew,part,sizeof(TParticle));
- } else partnew = part;
-
- // as the parent is always *before*, it must be already
- // in place. This is what we are checking anyway!
- if((parent=partnew->GetFirstMother())>fHgwmk) {
- if(map[parent]==-99) printf("map[%d] = -99!\n",parent);
- partnew->SetFirstMother(map[parent]);
- }
- nkeep++;
- }
- }
- fNtrack=nkeep;
-
- // Fix daughters information
- for (i=0; i<fNtrack; i++) {
- part = (TParticle *)particles.UncheckedAt(i);
- parent = part->GetFirstMother();
- if(parent>=0) {
- father = (TParticle *)particles.UncheckedAt(parent);
- if(father->TestBit(Daughters_Bit)) {
-
- if(i<father->GetFirstDaughter()) father->SetFirstDaughter(i);
- if(i>father->GetLastDaughter()) father->SetLastDaughter(i);
- } else {
- // Iitialise daughters info for first pass
- father->SetFirstDaughter(i);
- father->SetLastDaughter(i);
- father->SetBit(Daughters_Bit);
- }
- }
- }
-
-#ifdef old
- // Now loop on all detectors and reset the hits
- AliHit *OneHit;
- TIter next(fModules);
- AliModule *detector;
- while((detector = (AliModule*)next())) {
- if (!detector->Hits()) continue;
- TClonesArray &vHits=*(detector->Hits());
- if(vHits.GetEntries() != detector->GetNhits())
- printf("vHits.GetEntries()!=detector->GetNhits(): %d != %d\n",
- vHits.GetEntries(),detector->GetNhits());
- for (i=0; i<detector->GetNhits(); i++) {
- OneHit = (AliHit *)vHits.UncheckedAt(i);
- OneHit->SetTrack(map[OneHit->GetTrack()]);
- }
- }
-#else
-
- // Now loop on all registered hit lists
- TIter next(fHitLists);
- TCollection *hitList;
- while((hitList = (TCollection*)next())) {
- TIter nexthit(hitList);
- AliHit *hit;
- while((hit = (AliHit*)nexthit())) {
- hit->SetTrack(map[hit->GetTrack()]);
- }
- }
-#endif
-
- fHgwmk=nkeep-1;
- particles.SetLast(fHgwmk);
- delete [] map;
+ return fStack->Particle(i);
}
//_____________________________________________________________________________
void AliRun::BeginEvent()
{
+ // Clean-up previous event
+ // Energy scores
+ fEventEnergy.Reset();
+ // Clean detector information
+ CleanDetectors();
+ // Reset stack info
+ fStack->Reset();
+
+
//
// Reset all Detectors & kinematics & trees
//
char hname[30];
//
+ // Initialise event header
+ fHeader->Reset(fRun,fEvent);
+ //
+ fStack->BeginEvent(fEvent);
//
if(fLego) {
}
//
- ResetStack();
+
ResetHits();
ResetDigits();
+ ResetSDigits();
- // Initialise event header
- fHeader.Reset(fRun,fEvent);
- if(fTreeK) {
- fTreeK->Reset();
- sprintf(hname,"TreeK%d",fEvent);
- fTreeK->SetName(hname);
- }
if(fTreeH) {
fTreeH->Reset();
sprintf(hname,"TreeH%d",fEvent);
fTreeD->Reset();
sprintf(hname,"TreeD%d",fEvent);
fTreeD->SetName(hname);
+ fTreeD->Write(0,TObject::kOverwrite);
+ }
+ if(fTreeS) {
+ fTreeS->Reset();
+ sprintf(hname,"TreeS%d",fEvent);
+ fTreeS->SetName(hname);
+ fTreeS->Write(0,TObject::kOverwrite);
}
if(fTreeR) {
fTreeR->Reset();
sprintf(hname,"TreeR%d",fEvent);
fTreeR->SetName(hname);
+ fTreeR->Write(0,TObject::kOverwrite);
}
}
-
//_____________________________________________________________________________
void AliRun::ResetDigits()
{
}
}
+//_____________________________________________________________________________
+void AliRun::ResetSDigits()
+{
+ //
+ // Reset all Detectors digits
+ //
+ TIter next(fModules);
+ AliModule *detector;
+ while((detector = (AliModule*)next())) {
+ detector->ResetSDigits();
+ }
+}
+
//_____________________________________________________________________________
void AliRun::ResetHits()
{
if (!fInitDone) InitMC(setup);
// Create the Root Tree with one branch per detector
- MakeTree("KHDER");
+
+ MakeTree("ESDR");
+
+ if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
+ MakeTree("K","Kine.root");
+ MakeTree("H","Hits.root");
+ } else {
+ MakeTree("KH");
+ }
gMC->ProcessRun(nevent);
}
//_____________________________________________________________________________
-void AliRun::RunLego(const char *setup,Int_t ntheta,Float_t themin,
- Float_t themax,Int_t nphi,Float_t phimin,Float_t phimax,
- Float_t rmin,Float_t rmax,Float_t zmax)
+void AliRun::RunReco(const char *selected)
+{
+ //
+ // Main function to be called to reconstruct Alice event
+ //
+ cout << "Found "<< gAlice->TreeE()->GetEntries() << "events" << endl;
+ for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
+ cout << "Processing event "<< nevent << endl;
+ GetEvent(nevent);
+ // MakeTree("R");
+ Digits2Reco(selected);
+ }
+}
+
+//_____________________________________________________________________________
+
+void AliRun::Hits2Digits(const char *selected)
+{
+
+ // Convert Hits to sumable digits
+ //
+ for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
+ GetEvent(nevent);
+ // MakeTree("D");
+ Hits2SDigits(selected);
+ SDigits2Digits(selected);
+ }
+}
+
+
+//_____________________________________________________________________________
+
+void AliRun::Tree2Tree(Option_t *option, const char *selected)
+{
+ //
+ // Function to transform the content of
+ //
+ // - TreeH to TreeS (option "S")
+ // - TreeS to TreeD (option "D")
+ // - TreeD to TreeR (option "R")
+ //
+ // If multiple options are specified ("SDR"), transformation will be done in sequence for
+ // selected detector and for all detectors if none is selected (detector string
+ // can contain blank separated list of detector names).
+
+
+ const char *oS = strstr(option,"S");
+ const char *oD = strstr(option,"D");
+ const char *oR = strstr(option,"R");
+
+ TObjArray *detectors = Detectors();
+
+ TIter next(detectors);
+
+ AliDetector *detector = 0;
+
+ TDirectory *cwd = gDirectory;
+
+ char outFile[32];
+
+ while((detector = (AliDetector*)next())) {
+ 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 (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)
{
//
// Generates lego plots of:
// check if initialisation has been done
if (!fInitDone) InitMC(setup);
-
//Save current generator
AliGenerator *gen=Generator();
+ // Set new generator
+ if (!gener) gener = new AliLegoGenerator();
+ ResetGenerator(gener);
+ //
+ // Configure Generator
+ gener->SetRadiusRange(rmin, rmax);
+ gener->SetZMax(zmax);
+ gener->SetCoor1Range(nc1, c1min, c1max);
+ gener->SetCoor2Range(nc2, c2min, c2max);
+
+
//Create Lego object
- fLego = new AliLego("lego",ntheta,themin,themax,nphi,phimin,phimax,rmin,rmax,zmax);
+ fLego = new AliLego("lego",gener);
//Prepare MC for Lego Run
gMC->InitLego();
//Run Lego Object
- gMC->ProcessRun(ntheta*nphi+1);
+
+ gMC->ProcessRun(nc1*nc2+1);
// Create only the Root event Tree
MakeTree("E");
// End of this run, close files
FinishRun();
-
+ // Restore current generator
+ ResetGenerator(gen);
// Delete Lego Object
delete fLego; fLego=0;
+}
- // Restore current generator
- SetGenerator(gen);
+//_____________________________________________________________________________
+void AliRun::SetConfigFunction(const char * config)
+{
+ //
+ // Set the signature of the function contained in Config.C to configure
+ // the run
+ //
+ fConfigFunction=config;
}
//_____________________________________________________________________________
//
// Set current track number
//
- fCurrent = 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,
- const char *mecha, Int_t &ntr, Float_t weight)
+ AliMCProcess mech, Int_t &ntr, Float_t weight)
{
+// Delegate to stack
+//
+ fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
+ mech, ntr, weight);
+}
+
+//_____________________________________________________________________________
+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)
+{
+ // Delegate to stack
//
- // Load a track on the stack
- //
- // done 0 if the track has to be transported
- // 1 if not
- // parent identifier of the parent track. -1 for a primary
- // pdg particle code
- // pmom momentum GeV/c
- // vpos position
- // polar polarisation
- // tof time of flight in seconds
- // mecha production mechanism
- // ntr on output the number of the track stored
- //
- TClonesArray &particles = *fParticles;
- TParticle *particle;
- Float_t mass;
- const Int_t firstdaughter=-1;
- const Int_t lastdaughter=-1;
- const Int_t KS=0;
- // const Float_t tlife=0;
-
- //
- // Here we get the static mass
- // For MC is ok, but a more sophisticated method could be necessary
- // if the calculated mass is required
- // also, this method is potentially dangerous if the mass
- // used in the MC is not the same of the PDG database
- //
- mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
- Float_t e=TMath::Sqrt(mass*mass+pmom[0]*pmom[0]+
- pmom[1]*pmom[1]+pmom[2]*pmom[2]);
-
- //printf("Loading particle %s mass %f ene %f No %d ip %d pos %f %f %f mom %f %f %f KS %d m %s\n",
- //pname,mass,e,fNtrack,pdg,vpos[0],vpos[1],vpos[2],pmom[0],pmom[1],pmom[2],KS,mecha);
-
- particle=new(particles[fNtrack]) TParticle(pdg,KS,parent,-1,firstdaughter,
- lastdaughter,pmom[0],pmom[1],pmom[2],
- e,vpos[0],vpos[1],vpos[2],tof);
- // polar[0],polar[1],polar[2],tof,
- // mecha,weight);
- ((TParticle*)particles[fNtrack])->SetPolarisation(TVector3(polar[0],polar[1],polar[2]));
- ((TParticle*)particles[fNtrack])->SetWeight(weight);
- if(!done) particle->SetBit(Done_Bit);
- //Declare that the daughter information is valid
- ((TParticle*)particles[fNtrack])->SetBit(Daughters_Bit);
-
- if(parent>=0) {
- particle=(TParticle*) fParticles->UncheckedAt(parent);
- particle->SetLastDaughter(fNtrack);
- if(particle->GetFirstDaughter()<0) particle->SetFirstDaughter(fNtrack);
- } else {
- //
- // This is a primary track. Set high water mark for this event
- fHgwmk=fNtrack;
+ fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+ polx, poly, polz, mech, ntr, weight);
+
+}
+
+//_____________________________________________________________________________
+void AliRun::SetHighWaterMark(const Int_t nt)
+{
//
- // Set also number if primary tracks
- fHeader.SetNprimary(fHgwmk+1);
- fHeader.SetNtrack(fHgwmk+1);
- }
- ntr = fNtrack++;
+ // Set high water mark for last track in event
+ fStack->SetHighWaterMark(nt);
}
//_____________________________________________________________________________
void AliRun::KeepTrack(const Int_t track)
{
//
- // flags a track to be kept
+ // Delegate to stack
//
- TClonesArray &particles = *fParticles;
- ((TParticle*)particles[track])->SetBit(Keep_Bit);
+ fStack->KeepTrack(track);
}
//_____________________________________________________________________________
//Call the appropriate stepping routine;
AliModule *det = (AliModule*)fModules->At(id);
- if(det) det->StepManager();
+ if(det) {
+ fMCQA->StepManager(id);
+ det->StepManager();
+ }
}
}
//_____________________________________________________________________________
void AliRun::Streamer(TBuffer &R__b)
{
- //
- // Stream an object of class AliRun.
- //
- if (R__b.IsReading()) {
- Version_t R__v = R__b.ReadVersion(); if (R__v) { }
- TNamed::Streamer(R__b);
- if (!gAlice) gAlice = this;
- gROOT->GetListOfBrowsables()->Add(this,"Run");
- fTreeE = (TTree*)gDirectory->Get("TE");
- if (fTreeE) fTreeE->SetBranchAddress("Header", &header);
- else Error("Streamer","cannot find Header Tree\n");
- R__b >> fNtrack;
- R__b >> fHgwmk;
- R__b >> fDebug;
- fHeader.Streamer(R__b);
- R__b >> fModules;
- R__b >> fParticles;
- R__b >> fField;
- // R__b >> fMC;
- R__b >> fNdets;
- R__b >> fTrRmax;
- R__b >> fTrZmax;
- R__b >> fGenerator;
- if(R__v>1) {
- R__b >> fPDGDB; //Particle factory object!
+ // Stream an object of class AliRun.
+
+ if (R__b.IsReading()) {
+ if (!gAlice) gAlice = this;
+
+ AliRun::Class()->ReadBuffer(R__b, this);
+ //
+ gROOT->GetListOfBrowsables()->Add(this,"Run");
+
+ fTreeE = (TTree*)gDirectory->Get("TE");
+ if (fTreeE) {
+ fTreeE->SetBranchAddress("Header", &fHeader);
+ }
+
+ else Error("Streamer","cannot find Header Tree\n");
fTreeE->GetEntry(0);
- } else {
- fHeader.SetEvent(0);
- fPDGDB = TDatabasePDG::Instance(); //Particle factory object!
- }
- if(R__v>2) {
- fConfigFunction.Streamer(R__b);
- } else {
- fConfigFunction="Config();";
- }
- } else {
- R__b.WriteVersion(AliRun::IsA());
- TNamed::Streamer(R__b);
- R__b << fNtrack;
- R__b << fHgwmk;
- R__b << fDebug;
- fHeader.Streamer(R__b);
- R__b << fModules;
- R__b << fParticles;
- R__b << fField;
- // R__b << fMC;
- R__b << fNdets;
- R__b << fTrRmax;
- R__b << fTrZmax;
- R__b << fGenerator;
- R__b << fPDGDB; //Particle factory object!
- fConfigFunction.Streamer(R__b);
- }
-}
+
+ gRandom = fRandom;
+ } else {
+ AliRun::Class()->WriteBuffer(R__b, this);
+ }
+}
+
+
+//___________________________________________________________________________
+Int_t AliRun::CurrentTrack() const {
+ //
+ // Returns current track
+ //
+ return fStack->CurrentTrack();
+}
+
+//___________________________________________________________________________
+Int_t AliRun::GetNtrack() const {
+ //
+ // Returns number of tracks in stack
+ //
+ return fStack->GetNtrack();
+}
+
+//___________________________________________________________________________
+TObjArray* AliRun::Particles() {
+ //
+ // Returns pointer to Particles array
+ //
+ return fStack->Particles();
+}
+
+//___________________________________________________________________________
+TTree* AliRun::TreeK() {
+ //
+ // Returns pointer to the TreeK array
+ //
+ return fStack->TreeK();
+}
+
+
+void AliRun::SetGenEventHeader(AliGenEventHeader* header)
+{
+ fHeader->SetGenEventHeader(header);
+}