* provided "as is" without express or implied warranty. *
**************************************************************************/
-/*
-$Log$
-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$ */
///////////////////////////////////////////////////////////////////////////////
// //
// //
///////////////////////////////////////////////////////////////////////////////
-#include <stdlib.h>
+#include <Riostream.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <Riostream.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 <TCint.h>
+#include <TFile.h>
#include <TFolder.h>
+#include <TGeometry.h>
#include <TKey.h>
#include <TNode.h>
-#include "TParticle.h"
-#include "AliRun.h"
+#include <TObjectTable.h>
+#include <TParticle.h>
+#include <TROOT.h>
+#include <TRandom.h>
+#include <TRandom3.h>
+#include <TSystem.h>
+#include <TTree.h>
+#include <TVirtualMC.h>
+
+#include "AliConfig.h"
+#include "AliDetector.h"
#include "AliDisplay.h"
-#include "AliMC.h"
+#include "AliGenEventHeader.h"
+#include "AliGenerator.h"
+#include "AliHeader.h"
+#include "AliHit.h"
#include "AliLego.h"
+#include "AliLegoGenerator.h"
+#include "AliLoader.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 "AliStack.h"
-#include "AliGenEventHeader.h"
-#include "AliHeader.h"
-#include "AliDetector.h"
#include "AliPDG.h"
+#include "AliRun.h"
+#include "AliRunLoader.h"
+#include "AliStack.h"
AliRun *gAlice;
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),
fRandom(0),
fMCQA(0),
fTransParName("\0"),
- fBaseFileName("\0"),
- fStack(0),
- fTreeDFileName(""),
- fTreeDFile(0),
- fTreeSFileName(""),
- fTreeSFile(0),
- fTreeRFileName(""),
- fTreeRFile(0)
+ fRunLoader(0x0)
{
//
// Default constructor for AliRun
//
+ AliConfig::Instance();//skowron 29 Feb 2002
+ //ensures that the folder structure is build
}
//_______________________________________________________________________
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),
fRandom(0),
fMCQA(0),
fTransParName("\0"),
- fBaseFileName("\0"),
- fStack(0),
- fTreeDFileName(""),
- fTreeDFile(0),
- fTreeSFileName(""),
- fTreeSFile(0),
- fTreeRFileName(""),
- fTreeRFile(0)
+ fRunLoader(0x0)
{
//
// Copy constructor for AliRun
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),
fRandom(new TRandom3()),
fMCQA(0),
fTransParName("\0"),
- fBaseFileName("\0"),
- fStack(new AliStack(10000)), //Particle stack
- fTreeDFileName(""),
- fTreeDFile(0),
- fTreeSFileName(""),
- fTreeSFile(0),
- fTreeRFileName(""),
- fTreeRFile(0)
+ fRunLoader(0x0)
{
//
// Constructor for the main processor.
// Add to list of browsable
gROOT->GetListOfBrowsables()->Add(this,name);
-
// Create the TNode geometry for the event display
BuildSimpleGeometry();
//
// Default AliRun destructor
//
- TFile *curfil =0;
- if(fTreeE)curfil=fTreeE->GetCurrentFile();
+ gROOT->GetListOfBrowsables()->Remove(this);
+
+ if (fRunLoader)
+ {
+ TFolder* evfold = fRunLoader->GetEventFolder();
+ TFolder* modfold = dynamic_cast<TFolder*>(evfold->FindObjectAny(AliConfig::GetModulesFolderName()));
+ TIter next(fModules);
+ AliModule *mod;
+ while((mod = (AliModule*)next()))
+ {
+ modfold->Remove(mod);
+ }
+ }
+
delete fImedia;
delete fField;
- delete fMC;
+ // delete fMC;
+ delete gMC; gMC=0;
delete fGeometry;
delete fDisplay;
delete fGenerator;
delete fLego;
- delete fTreeD;
- delete fTreeH;
- delete fTreeTR;
- delete fTreeE;
- delete fTreeR;
- delete fTreeS;
if (fModules) {
fModules->Delete();
delete fModules;
}
- delete fStack;
+
delete fHitLists;
delete fPDGDB;
delete fMCQA;
- delete fHeader;
- // avoid to delete TFile objects not owned by this object
- // avoid multiple deletions
- if(curfil == fTreeDFile) fTreeDFile=0;
- if(curfil == fTreeSFile) fTreeSFile=0;
- if(curfil == fTreeRFile) fTreeRFile=0;
- if(fTreeSFile == fTreeDFile) fTreeSFile=0;
- if(fTreeRFile == fTreeDFile) fTreeRFile=0;
- if(fTreeRFile == fTreeSFile) fTreeRFile=0;
- if(fTreeDFile){
- if(fTreeDFile->IsOpen())fTreeDFile->Close();
- delete fTreeDFile;
- }
- if(fTreeSFile){
- if(fTreeSFile->IsOpen())fTreeSFile->Close();
- delete fTreeSFile;
- }
- if(fTreeRFile){
- if(fTreeRFile->IsOpen())fTreeRFile->Close();
- delete fTreeRFile;
- }
- if (gROOT->GetListOfBrowsables())
- gROOT->GetListOfBrowsables()->Remove(this);
-
- gAlice=0;
}
//_______________________________________________________________________
// of the Root browser.
// It displays the Root Trees and all detectors.
//
- if(!fStack) fStack=fHeader->Stack();
- TTree* pTreeK = fStack->TreeK();
-
- if (pTreeK) b->Add(pTreeK,pTreeK->GetName());
- if (fTreeH) b->Add(fTreeH,fTreeH->GetName());
- if (fTreeTR) b->Add(fTreeTR,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 = dynamic_cast<AliModule*>(next()))) {
- b->Add(detector,detector->GetName());
- }
+ //detectors are in folders anyway
b->Add(fMCQA,"AliMCQA");
}
//
// Clean Detectors at the end of event
//
- TIter next(fModules);
- AliModule *detector;
- while((detector = dynamic_cast<AliModule*>(next()))) {
- detector->FinishEvent();
- }
+ fRunLoader->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
//
// Dumps particle i in the stack
//
- fStack->DumpPart(i);
+ if (fRunLoader->Stack())
+ fRunLoader->Stack()->DumpPart(i);
}
//_______________________________________________________________________
//
// Dumps the particle stack
//
- fStack->DumpPStack();
+ if (fRunLoader->Stack())
+ fRunLoader->Stack()->DumpPStack();
}
//_______________________________________________________________________
Warning("SetField","Invalid map %d\n",version);
}
}
-
-//_______________________________________________________________________
+
+//_____________________________________________________________________________
+
+void AliRun::InitLoaders()
+{
+ //creates list of getters
+ if (GetDebug()) Info("InitLoaders","");
+ TIter next(fModules);
+ AliModule *mod;
+ while((mod = (AliModule*)next()))
+ {
+ AliDetector *det = dynamic_cast<AliDetector*>(mod);
+ if (det)
+ {
+ if (GetDebug()) Info("InitLoaders"," Adding %s ",det->GetName());
+ fRunLoader->AddLoader(det);
+ }
+ }
+ if (GetDebug()) Info("InitLoaders","Done");
+}
+//_____________________________________________________________________________
+
void AliRun::FinishRun()
{
//
// Called at the end of the run.
//
-
- //
- if(fLego) fLego->FinishRun();
+
+
+ if(fLego)
+ {
+ if (GetDebug()) Info("FinishRun"," Finish Lego");
+ fRunLoader->CdGAFile();
+ fLego->FinishRun();
+ }
// Clean detector information
TIter next(fModules);
AliModule *detector;
while((detector = dynamic_cast<AliModule*>(next()))) {
+ if (GetDebug()) Info("FinishRun"," %s->FinishRun()",detector->GetName());
detector->FinishRun();
}
//Output energy summary tables
+ if (GetDebug()) Info("FinishRun"," EnergySummary()");
EnergySummary();
-
- TFile *file = fTreeE->GetCurrentFile();
-
- file->cd();
-
- fTreeE->Write(0,TObject::kOverwrite);
- // Write AliRun info and all detectors parameters
- Write(0,TObject::kOverwrite);
+ if (GetDebug()) Info("FinishRun"," fRunLoader->WriteHeader(OVERWRITE)");
+ fRunLoader->WriteHeader("OVERWRITE");
+ // Write AliRun info and all detectors parameters
+ fRunLoader->CdGAFile();
+ Write(0,TObject::kOverwrite);//write AliRun
+ fRunLoader->Write(0,TObject::kOverwrite);//write RunLoader itself
+
// Clean tree information
+ if (GetDebug()) Info("FinishRun"," fRunLoader->Stack()->FinishRun()");
+ fRunLoader->Stack()->FinishRun();
- fStack->FinishRun();
-
- if (fTreeH) {
- delete fTreeH; fTreeH = 0;
- }
- if (fTreeTR) {
- delete fTreeTR; fTreeTR = 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;
- }
+ // Clean detector information
+ if (GetDebug()) Info("FinishRun"," fGenerator->FinishRun()");
fGenerator->FinishRun();
-
- // Close output file
- file->Write();
}
//_______________________________________________________________________
{
// Delegate to stack
//
- fStack->FlagTrack(track);
+ fRunLoader->Stack()->FlagTrack(track);
}
//_______________________________________________________________________
Float_t ed, ed2;
Int_t kn, i, left, j, id;
const Float_t kzero=0;
- Int_t ievent=fHeader->GetEvent()+1;
+ Int_t ievent=fRunLoader->GetHeader()->GetEvent()+1;
//
// Energy loss information
if(ievent) {
// 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 NewIO\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
{
//_______________________________________________________________________
Int_t AliRun::GetEvent(Int_t event)
{
- //
- // Connect the Trees Kinematics and Hits for event # event
- // Set branch addresses
- //
-
- // Reset existing structures
+//
+// Reloads data containers in folders # event
+// Set branch addresses
+//
+ if (fRunLoader == 0x0)
+ {
+ Error("GetEvent","RunLoader is not set. Can not load data.");
+ return -1;
+ }
+/*****************************************/
+/**** P R E R E L O A D I N G ****/
+/*****************************************/
+// Reset existing structures
ResetHits();
ResetTrackReferences();
ResetDigits();
ResetSDigits();
-
- // Delete Trees already connected
- if (fTreeH) { delete fTreeH; fTreeH = 0;}
- if (fTreeTR) { delete fTreeTR; fTreeTR = 0;}
- if (fTreeD) { delete fTreeD; fTreeD = 0;}
- if (fTreeR) { delete fTreeR; fTreeR = 0;}
- if (fTreeS) { delete fTreeS; fTreeS = 0;}
-
- // Create the particle stack
- if (fHeader) delete fHeader;
- fHeader = 0;
-
- // Get header from file
- if(fTreeE) {
- fTreeE->SetBranchAddress("Header", &fHeader);
-
- if (!fTreeE->GetEntry(event)) {
- Error("GetEvent","Cannot find event:%d\n",event);
- return -1;
- }
- }
- else {
- Error("GetEvent","Cannot find Header Tree (TE)\n");
- return -1;
- }
-
- // Get the stack from the header, set fStack to 0 if it
- // fails to get event
- //
- TFile *file = fTreeE->GetCurrentFile();
- char treeName[20];
-
- file->cd();
-
- if (fStack) delete fStack;
- fStack = fHeader->Stack();
- if (fStack) {
- if (!fStack->GetEvent(event)) fStack = 0;
- }
-
- // Get Hits Tree header from file
- sprintf(treeName,"TreeH%d",event);
- fTreeH = dynamic_cast<TTree*>(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 = dynamic_cast<TTree*>(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=static_cast<TString>(fTreeE->GetCurrentFile()->GetName());
- if(fTreeDFileName==curfilname)fTreeDFileName="";
- if(fTreeSFileName==curfilname)fTreeSFileName="";
- if(fTreeRFileName==curfilname)fTreeRFileName="";
-
- // Get Digits Tree header from file
- sprintf(treeName,"TreeD%d",event);
- if (!fTreeDFile && fTreeDFileName != "") {
- InitTreeFile("D",fTreeDFileName);
- }
- if (fTreeDFile) {
- fTreeD = dynamic_cast<TTree*>(fTreeDFile->Get(treeName));
- } else {
- fTreeD = dynamic_cast<TTree*>(file->Get(treeName));
- }
- if (!fTreeD) {
- // Warning("GetEvent","cannot find Digits Tree for event:%d\n",event);
- }
- if(fTreeDFileName != ""){
- if(fTreeDFileName==fTreeSFileName) {
- fTreeSFileName = "";
- fTreeSFile = fTreeDFile;
- }
- if(fTreeDFileName==fTreeRFileName) {
- fTreeRFileName = "";
- fTreeRFile = fTreeDFile;
- }
- }
+/*****************************************/
+/**** R E L O A D ****/
+/*****************************************/
- file->cd();
+ fRunLoader->GetEvent(event);
- // Get SDigits Tree header from file
- sprintf(treeName,"TreeS%d",event);
- if (!fTreeSFile && fTreeSFileName != "") {
- InitTreeFile("S",fTreeSFileName);
- }
- if (fTreeSFile) {
- fTreeS = dynamic_cast<TTree*>(fTreeSFile->Get(treeName));
- } else {
- fTreeS = dynamic_cast<TTree*>(gDirectory->Get(treeName));
- }
- if (!fTreeS) {
- // Warning("GetEvent","cannot find SDigits Tree for event:%d\n",event);
- }
-
- if(fTreeSFileName != ""){
- if(fTreeSFileName==fTreeRFileName){
- fTreeRFileName = "";
- fTreeRFile = fTreeSFile;
- }
- }
+/*****************************************/
+/**** P O S T R E L O A D I N G ****/
+/*****************************************/
- file->cd();
-
- // Get Reconstruct Tree header from file
- sprintf(treeName,"TreeR%d",event);
- if (!fTreeRFile && fTreeRFileName != "") {
- InitTreeFile("R",fTreeRFileName);
- }
- if(fTreeRFile) {
- fTreeR = dynamic_cast<TTree*>(fTreeRFile->Get(treeName));
- } else {
- fTreeR = dynamic_cast<TTree*>(gDirectory->Get(treeName));
- }
- if (!fTreeR) {
- // printf("WARNING: cannot find Reconstructed Tree for event:%d\n",event);
- }
-
- file->cd();
-
// Set Trees branch addresses
TIter next(fModules);
AliModule *detector;
- while((detector = dynamic_cast<AliModule*>(next()))) {
- detector->SetTreeAddress();
- }
-
- fEvent=event; //MI change
-
- return fHeader->GetNtrack();
+ while((detector = dynamic_cast<AliModule*>(next())))
+ {
+ detector->SetTreeAddress();
+ }
+
+ return fRunLoader->GetHeader()->GetNtrack();
}
//_______________________________________________________________________
//
// return number of primary that has generated track
//
- return fStack->GetPrimary(track);
+ return fRunLoader->Stack()->GetPrimary(track);
}
//_______________________________________________________________________
// Built media table to get from the media number to
// the detector id
//
+
Int_t kz, nz, idt, lz, i, k, ind;
// Int_t ibeg;
TObjArray &dets = *gAlice->Detectors();
//_______________________________________________________________________
void AliRun::SetTransPar(const char *filename)
{
+ //
+ // Sets the file name for transport parameters
+ //
fTransParName = filename;
}
}
}
}
+//_____________________________________________________________________________
-
-//_______________________________________________________________________
-void AliRun::MakeTree(Option_t *option, const char *file)
+void AliRun::BeginEvent()
{
//
- // Create the ROOT trees
- // Loop on all detectors to create the Root branch (if any)
- //
-
- char hname[30];
- //
- // Analyse options
- const char *oK = strstr(option,"K");
- const char *oH = strstr(option,"H");
- const char *oTR = strstr(option,"T");
- 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;
+ // Clean-up previous event
+ // Energy scores
+ if (GetDebug())
+ {
+ Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ Info("BeginEvent"," BEGINNING EVENT ");
+ Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ Info("BeginEvent",">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+ }
+
+ /*******************************/
+ /* Clean after eventual */
+ /* previous event */
+ /*******************************/
- 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 = fTreeE->Branch("Header", "AliHeader", &fHeader, 4000, 0);
- branch->SetAutoDelete(kFALSE);
- TFolder *folder = dynamic_cast<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=dynamic_cast<TBranch*>(next()))) {
- branch->SetFile(outFile);
- }
- if (GetDebug()>1)
- printf("* MakeBranch * Diverting Branch %s to file %s\n", branch->GetName(),file);
- cwd->cd();
- delete outFile;
- }
+ //Set the next event in Run Loader -> Cleans trees (TreeK and all trees in detectors),
+ fRunLoader->SetEventNumber(++fEventNrInRun);// sets new files, cleans the previous event stuff, if necessary, etc.,
+ if (GetDebug()) Info("BeginEvent","EventNr is %d",fEventNrInRun);
+
+ fEventEnergy.Reset();
+ // Clean detector information
- if (oH && !fTreeH) {
- sprintf(hname,"TreeH%d",fEvent);
- fTreeH = new TTree(hname,"Hits");
- fTreeH->SetAutoSave(1000000000); //no autosave
- fTreeH->Write(0,TObject::kOverwrite);
- }
+ if (fRunLoader->Stack())
+ fRunLoader->Stack()->Reset();//clean stack -> tree is unloaded
+ else
+ fRunLoader->MakeStack();//or make a new one
+
+ if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(K)");
+ fRunLoader->MakeTree("K");
+ if (GetDebug()) Info("BeginEvent"," gMC->SetStack(fRunLoader->Stack())");
+ gMC->SetStack(fRunLoader->Stack());//Was in InitMC - but was moved here
+ //because we don't have guarantee that
+ //stack pointer is not going to change from event to event
+ //since it bellobgs to header and is obtained via RunLoader
+ //
+ // Reset all Detectors & kinematics & make/reset trees
+ //
+
+ fRunLoader->GetHeader()->Reset(fRun,fEvent,fEventNrInRun);
+// fRunLoader->WriteKinematics("OVERWRITE"); is there any reason to rewrite here since MakeTree does so
- if (oTR && !fTreeTR) {
- sprintf(hname,"TreeTR%d",fEvent);
- fTreeTR = new TTree(hname,"TrackReferences");
- fTreeTR->SetAutoSave(1000000000); //no autosave
- fTreeTR->Write(0,TObject::kOverwrite);
- }
+ if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTrackRefsContainer()");
+ fRunLoader->MakeTrackRefsContainer();//for insurance
- 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 (oR && !fTreeR) {
- sprintf(hname,"TreeR%d",fEvent);
- fTreeR = new TTree(hname,"Reconstruction");
- fTreeR->Write(0,TObject::kOverwrite);
- }
+ if (GetDebug()) Info("BeginEvent"," ResetHits()");
+ ResetHits();
+ if (GetDebug()) Info("BeginEvent"," fRunLoader->MakeTree(H)");
+ fRunLoader->MakeTree("H");
//
- // Create a branch for hits/digits for each detector
- // Each branch is a TClonesArray. Each data member of the Hits classes
- // will be in turn a subbranch of the detector master branch
+ if(fLego)
+ {
+ fLego->BeginEvent();
+ return;
+ }
+
+ //create new branches and SetAdresses
TIter next(fModules);
AliModule *detector;
- while((detector = dynamic_cast<AliModule*>(next()))) {
- if (oH) detector->MakeBranch(option,file);
- if (oTR) detector->MakeBranchTR(option,file);
- }
+ while((detector = (AliModule*)next()))
+ {
+ if (GetDebug()) Info("BeginEvent"," %s->MakeBranch(H)",detector->GetName());
+ detector->MakeBranch("H");
+ if (GetDebug()) Info("BeginEvent"," %s->MakeBranchTR()",detector->GetName());
+ detector->MakeBranchTR();
+ if (GetDebug()) Info("BeginEvent"," %s->SetTreeAddress()",detector->GetName());
+ detector->SetTreeAddress();
+ }
}
//_______________________________________________________________________
-TParticle* AliRun::Particle(Int_t i)
+TParticle* AliRun::Particle(Int_t i) const
{
- return fStack->Particle(i);
+ if (fRunLoader)
+ if (fRunLoader->Stack())
+ return fRunLoader->Stack()->Particle(i);
+ return 0x0;
}
//_______________________________________________________________________
detector->ResetHits();
}
}
-
//_______________________________________________________________________
+
void AliRun::ResetTrackReferences()
{
//
detector->ResetTrackReferences();
}
}
-
//_______________________________________________________________________
+
void AliRun::ResetPoints()
{
//
detector->ResetPoints();
}
}
-
//_______________________________________________________________________
+
void AliRun::InitMC(const char *setup)
{
//
// Initialize the Alice setup
//
+ Announce();
if(fInitDone) {
Warning("Init","Cannot initialise AliRun twice!\n");
// Register MC in configuration
AliConfig::Instance()->Add(gMC);
- gMC->SetStack(fStack);
+
+ InitLoaders();
+
+ fRunLoader->MakeTree("E");
+ fRunLoader->LoadKinematics("RECREATE");
+ fRunLoader->LoadTrackRefs("RECREATE");
+ fRunLoader->LoadHits("all","RECREATE");
+
+
+ fRunLoader->CdGAFile();
gMC->DefineParticles(); //Create standard MC particles
AliPDG::AddParticlesToPdgDataBase();
// Added also after in case of interactive initialisation of modules
fNdets = fModules->GetLast()+1;
- TIter next(fModules);
- AliModule *detector;
- while((detector = dynamic_cast<AliModule*>(next()))) {
- detector->SetTreeAddress();
- objlast = gDirectory->GetList()->Last();
+ TIter next(fModules);
+ AliModule *detector;
+ while((detector = dynamic_cast<AliModule*>(next())))
+ {
+ objlast = gDirectory->GetList()->Last();
- // Add Detector histograms in Detector list of histograms
- if (objlast) objfirst = gDirectory->GetList()->After(objlast);
- else objfirst = gDirectory->GetList()->First();
- while (objfirst) {
+ // Add Detector histograms in Detector list of histograms
+ if (objlast) objfirst = gDirectory->GetList()->After(objlast);
+ else objfirst = gDirectory->GetList()->First();
+ while (objfirst)
+ {
detector->Histograms()->Add(objfirst);
objfirst = gDirectory->GetList()->After(objfirst);
}
gMC->BuildPhysics();
//Write Geometry object to current file.
- fGeometry->Write();
+ fRunLoader->WriteGeometry();
fInitDone = kTRUE;
fMCQA = new AliMCQA(fNdets);
- AliConfig::Instance();
//
// Save stuff at the beginning of the file to avoid file corruption
Write();
+ fEventNrInRun = -1; //important - we start Begin event from increasing current number in run
}
//_______________________________________________________________________
+
void AliRun::RunMC(Int_t nevent, const char *setup)
{
//
// a positive number of events will cause the finish routine
// to be called
//
- fEventsPerRun = nevent;
+ fEventsPerRun = nevent;
// check if initialisation has been done
if (!fInitDone) InitMC(setup);
// Create the Root Tree with one branch per detector
-
- MakeTree("ESDRT");
-
- if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
- MakeTree("K","Kine.root");
- MakeTree("H","Hits.root");
- } else {
- MakeTree("KH");
- }
+ //Hits moved to begin event -> now we are crating separate tree for each event
gMC->ProcessRun(nevent);
//
// Main function to be called to reconstruct Alice event
//
- cout << "Found "<< gAlice->TreeE()->GetEntries() << "events" << endl;
+ Int_t nev = fRunLoader->GetNumberOfEvents();
+ if (GetDebug()) Info("RunReco","Found %d events",nev);
Int_t nFirst = first;
- Int_t nLast = (last < 0)? static_cast<Int_t>(gAlice->TreeE()->GetEntries()) : last;
+ Int_t nLast = (last < 0)? nev : last;
for (Int_t nevent = nFirst; nevent <= nLast; nevent++) {
- cout << "Processing event "<< nevent << endl;
+ if (GetDebug()) Info("RunReco","Processing event %d",nevent);
GetEvent(nevent);
- // MakeTree("R");
Digits2Reco(selected);
}
}
//
for (Int_t nevent=0; nevent<gAlice->TreeE()->GetEntries(); nevent++) {
GetEvent(nevent);
- // MakeTree("D");
Hits2SDigits(selected);
SDigits2Digits(selected);
}
AliDetector *detector = 0;
- TDirectory *cwd = gDirectory;
-
- char outFile[32];
-
while((detector = dynamic_cast<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);
- }
+ if (detector->IsActive())
+ {
- cwd->cd();
-
- if (oS) {
- cout << "Hits2SDigits: Processing " << detector->GetName() << "..." << endl;
- detector->Hits2SDigits();
- }
- if (oD) {
- cout << "SDigits2Digits: Processing " << detector->GetName() << "..." << endl;
+ AliLoader* loader = detector->GetLoader();
+ if (loader == 0x0) continue;
+
+ if (oS)
+ {
+ if (GetDebug()) Info("Tree2Tree","Processing Hits2SDigits for %s ...",detector->GetName());
+ loader->LoadHits("read");
+ if (loader->TreeS() == 0x0) loader->MakeTree("S");
+ detector->MakeBranch(option);
+ detector->SetTreeAddress();
+ detector->Hits2SDigits();
+ loader->UnloadHits();
+ loader->UnloadSDigits();
+ }
+ if (oD)
+ {
+ if (GetDebug()) Info("Tree2Tree","Processing SDigits2Digits for %s ...",detector->GetName());
+ loader->LoadSDigits("read");
+ if (loader->TreeD() == 0x0) loader->MakeTree("D");
+ detector->MakeBranch(option);
+ detector->SetTreeAddress();
detector->SDigits2Digits();
- }
- if (oR) {
- cout << "Digits2Reco: Processing " << detector->GetName() << "..." << endl;
+ loader->UnloadSDigits();
+ loader->UnloadDigits();
+ }
+ if (oR)
+ {
+ if (GetDebug()) Info("Tree2Tree","Processing Digits2Reco for %s ...",detector->GetName());
+ loader->LoadDigits("read");
+ if (loader->TreeR() == 0x0) loader->MakeTree("R");
+ detector->MakeBranch(option);
+ detector->SetTreeAddress();
detector->Digits2Reco();
- }
-
- cwd->cd();
+ loader->UnloadDigits();
+ loader->UnloadRecPoints();
+
+ }
}
}
}
-
//_______________________________________________________________________
void AliRun::RunLego(const char *setup, Int_t nc1, Float_t c1min,
Float_t c1max,Int_t nc2,Float_t c2min,Float_t c2max,
gMC->ProcessRun(nc1*nc2);
// Create only the Root event Tree
- MakeTree("E");
+ fRunLoader->MakeTree("E");
// End of this run, close files
FinishRun();
//
// Set current track number
//
- fStack->SetCurrentTrack(track);
+ fRunLoader->Stack()->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)
+void AliRun::PushTrack(Int_t done, Int_t parent, Int_t pdg, Float_t *pmom,
+ Float_t *vpos, Float_t *polar, Float_t tof,
+ TMCProcess mech, Int_t &ntr, Float_t weight, Int_t is)
{
// Delegate to stack
//
-
- fStack->SetTrack(done, parent, pdg, pmom, vpos, polar, tof,
- mech, ntr, weight, is);
+ fRunLoader->Stack()->PushTrack(done, parent, pdg, pmom, vpos, polar, tof,
+ mech, ntr, weight, is);
}
//_______________________________________________________________________
-void AliRun::SetTrack(Int_t done, Int_t parent, Int_t pdg,
+void AliRun::PushTrack(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
//
- fStack->SetTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
- polx, poly, polz, mech, ntr, weight, is);
-
+ fRunLoader->Stack()->PushTrack(done, parent, pdg, px, py, pz, e, vx, vy, vz, tof,
+ polx, poly, polz, mech, ntr, weight, is);
}
//_______________________________________________________________________
{
//
// Set high water mark for last track in event
- fStack->SetHighWaterMark(nt);
+ fRunLoader->Stack()->SetHighWaterMark(nt);
}
//_______________________________________________________________________
//
// Delegate to stack
//
- fStack->KeepTrack(track);
+ fRunLoader->Stack()->KeepTrack(track);
}
//
TStopwatch stw;
TIter next(fModules);
AliModule *detector;
- printf("Geometry creation:\n");
+ if (GetDebug()) Info("ConstructGeometry","Geometry creation:");
while((detector = dynamic_cast<AliModule*>(next()))) {
stw.Start();
// Initialise detector materials and geometry
detector->CreateMaterials();
detector->CreateGeometry();
printf("%10s R:%.2fs C:%.2fs\n",
- detector->GetName(),stw.RealTime(),stw.CpuTime());
+ detector->GetName(),stw.RealTime(),stw.CpuTime());
}
}
}
}
-
//_______________________________________________________________________
+
void AliRun::GeneratePrimaries()
{
//
Generator()->Generate();
}
-
//_______________________________________________________________________
-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,fEventNrInRun);
- //
- fStack->BeginEvent(fEvent);
-
- //
- if(fLego) {
- fLego->BeginEvent();
- return;
- }
-
- //
-
- ResetHits();
- ResetTrackReferences();
- ResetDigits();
- ResetSDigits();
-
-
- if(fTreeH) {
- fTreeH->Reset();
- sprintf(hname,"TreeH%d",fEvent);
- fTreeH->SetName(hname);
- }
- if(fTreeTR) {
- fTreeTR->Reset();
- sprintf(hname,"TreeTR%d",fEvent);
- fTreeTR->SetName(hname);
- }
-
- if(fTreeD) {
- 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::BeginPrimary()
{
//
// static Int_t count=0;
// const Int_t times=10;
// This primary is finished, purify stack
- fStack->PurifyKine();
+ fRunLoader->Stack()->PurifyKine();
TIter next(fModules);
AliModule *detector;
while((detector = dynamic_cast<AliModule*>(next()))) {
detector->FinishPrimary();
+ if(detector->GetLoader())
+ {
+ detector->GetLoader()->TreeH()->Fill();
+ }
}
- // Write out hits if any
- if (gAlice->TreeH()) {
- gAlice->TreeH()->Fill();
- }
-
- // Write out hits if any
- if (gAlice->TreeTR()) {
- gAlice->TreeTR()->Fill();
- }
-
- //
- // if(++count%times==1) gObjectTable->Print();
+ // Write out track references if any
+ if (fRunLoader->TreeTR())
+ {
+ fRunLoader->TreeTR()->Fill();
+ }
}
//_______________________________________________________________________
//
if(fLego) fLego->FinishEvent();
+ TIter next(fModules);
+ AliModule *detector;
+ while((detector = dynamic_cast<AliModule*>(next()))) {
+ detector->FinishEvent();
+ }
+
//Update the energy deposit tables
Int_t i;
- for(i=0;i<fEventEnergy.GetSize();i++) {
+ for(i=0;i<fEventEnergy.GetSize();i++)
+ {
fSummEnergy[i]+=fEventEnergy[i];
fSum2Energy[i]+=fEventEnergy[i]*fEventEnergy[i];
- }
-
+ }
-
+ AliHeader* header = fRunLoader->GetHeader();
+ AliStack* stack = fRunLoader->Stack();
+ if ( (header == 0x0) || (stack == 0x0) )
+ {//check if we got header and stack. If not cry and exit aliroot
+ Fatal("AliRun","Can not get the stack or header from LOADER");
+ return;//never reached
+ }
// Update Header information
-
- fHeader->SetNprimary(fStack->GetNprimary());
- fHeader->SetNtrack(fStack->GetNtrack());
+ header->SetNprimary(stack->GetNprimary());
+ header->SetNtrack(stack->GetNtrack());
// Write out the kinematics
- fStack->FinishEvent();
+ stack->FinishEvent();
// Write out the event Header information
- if (fTreeE) {
- fHeader->SetStack(fStack);
- fTreeE->Fill();
- }
-
-
- // Write Tree headers
- TTree* pTreeK = fStack->TreeK();
- if (pTreeK) pTreeK->Write(0,TObject::kOverwrite);
- if (fTreeH) fTreeH->Write(0,TObject::kOverwrite);
- if (fTreeTR) fTreeTR->Write(0,TObject::kOverwrite);
+ TTree* treeE = fRunLoader->TreeE();
+ if (treeE)
+ {
+ header->SetStack(stack);
+ treeE->Fill();
+ }
+ else
+ {
+ Error("FinishEvent","Can not get TreeE from RL");
+ }
- ++fEvent;
- ++fEventNrInRun;
+ fRunLoader->WriteKinematics("OVERWRITE");
+ fRunLoader->WriteTrackRefs("OVERWRITE");
+ fRunLoader->WriteHits("OVERWRITE");
+
+ if (GetDebug())
+ {
+ Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+ Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+ Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+ Info("FinishEvent"," FINISHING EVENT ");
+ Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+ Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+ Info("FinishEvent","<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
+ }
}
//_______________________________________________________________________
if (R__b.IsReading()) {
if (!gAlice) gAlice = this;
-
AliRun::Class()->ReadBuffer(R__b, this);
- //
gROOT->GetListOfBrowsables()->Add(this,"Run");
- fTreeE = dynamic_cast<TTree*>(gDirectory->Get("TE"));
- if (fTreeE) {
- fTreeE->SetBranchAddress("Header", &fHeader);
- }
- else Error("Streamer","cannot find Header Tree\n");
-
- fTreeE->GetEntry(0);
gRandom = fRandom;
} else {
AliRun::Class()->WriteBuffer(R__b, this);
//_______________________________________________________________________
-Int_t AliRun::CurrentTrack() const {
+Int_t AliRun::GetCurrentTrackNumber() const {
//
// Returns current track
//
- return fStack->CurrentTrack();
+ return fRunLoader->Stack()->GetCurrentTrackNumber();
}
//_______________________________________________________________________
//
// Returns number of tracks in stack
//
- return fStack->GetNtrack();
+ return fRunLoader->Stack()->GetNtrack();
}
-
//_______________________________________________________________________
-TObjArray* AliRun::Particles() {
- //
- // Returns pointer to Particles array
- //
- return fStack->Particles();
-}
//_______________________________________________________________________
-TTree* AliRun::TreeK() {
+TObjArray* AliRun::Particles() const {
//
- // Returns pointer to the TreeK array
+ // Returns pointer to Particles array
//
- return fStack->TreeK();
+ if (fRunLoader)
+ if (fRunLoader->Stack())
+ return fRunLoader->Stack()->Particles();
+ return 0x0;
}
+//___________________________________________________________________________
//_______________________________________________________________________
void AliRun::SetGenEventHeader(AliGenEventHeader* header)
{
- fHeader->SetGenEventHeader(header);
+ fRunLoader->GetHeader()->SetGenEventHeader(header);
}
-//_______________________________________________________________________
-TFile* AliRun::InitFile(TString fileName)
-{
-//
-// create the file where the whole tree will be saved
-//
- TDirectory *wd = gDirectory;
- TFile* file = TFile::Open(fileName,"update");
- gDirectory = wd;
- if (!file->IsOpen()) {
- Error("Cannot open file, %s\n",fileName);
- return 0;
- }
- return file;
-}
+//___________________________________________________________________________
-//_______________________________________________________________________
-TFile* AliRun::InitTreeFile(Option_t *option, TString fileName)
-{
- //
- // create the file where one of the following trees will be saved
- // trees: S,D,R
- // WARNING: by default these trees are saved on the file on which
- // hits are stored. If you divert one of these trees, you cannot restore
- // it to the original file (usually galice.root) in the same aliroot session
- Bool_t oS = (strstr(option,"S")!=0);
- Bool_t oR = (strstr(option,"R")!=0);
- Bool_t oD = (strstr(option,"D")!=0);
- Int_t choice[3];
- for (Int_t i=0; i<3; i++) choice[i] = 0;
- if(oS)choice[0] = 1;
- if(oD)choice[1] = 1;
- if(oR)choice[2] = 1;
-
- TFile *ptr=0;
-
- if(!(oS || oR || oD))return ptr;
-
- Int_t active[3];
- for (Int_t i=0; i<3; i++) active[i] = 0;
- if(fTreeSFileName != "") active[0] = 1;
- if(fTreeDFileName != "") active[1] = 1;
- if(fTreeDFileName != "") active[2] = 1;
-
- Bool_t alreadyopen1 = kFALSE;
- Bool_t alreadyopen2 = kFALSE;
-
- if(oS){
- // if already active and same name with non-null ptr
- if(active[0]==1 && fileName == fTreeSFileName && fTreeSFile){
- Warning("InitTreeFile","File %s already opened",fTreeSFileName.Data());
- ptr = fTreeSFile;
- }
- else {
- // if already active with different name with non-null ptr
- if(active[0]==1 && fileName != fTreeSFileName && fTreeSFile){
- // close the active files and also the other possible files in option
- CloseTreeFile(option);
- }
- fTreeSFileName = fileName;
- alreadyopen1 =
- (active[1] == 1 && fTreeDFileName == fTreeSFileName && fTreeDFile);
- alreadyopen2 =
- (active[2] == 1 && fTreeRFileName == fTreeSFileName && fTreeRFile);
- if(!(alreadyopen1 || alreadyopen2)){
- ptr = InitFile(fileName);
- fTreeSFile = ptr;
- }
- else {
- if(alreadyopen1){fTreeSFile = fTreeDFile; ptr = fTreeSFile;}
- if(alreadyopen2){fTreeSFile = fTreeRFile; ptr = fTreeSFile;}
- }
- if(choice[1] == 1) { fTreeDFileName = fileName; fTreeDFile = ptr;}
- if(choice[2] == 1) { fTreeRFileName = fileName; fTreeRFile = ptr;}
- }
- return ptr;
- }
-
- if(oD){
- // if already active and same name with non-null ptr
- if(active[1]==1 && fileName == fTreeDFileName && fTreeDFile){
- Warning("InitTreeFile","File %s already opened",fTreeDFileName.Data());
- ptr = fTreeDFile;
- }
- else {
- // if already active with different name with non-null ptr
- if(active[1]==1 && fileName != fTreeDFileName && fTreeDFile){
- // close the active files and also the other possible files in option
- CloseTreeFile(option);
- }
- fTreeDFileName = fileName;
- alreadyopen1 =
- (active[0] == 1 && fTreeSFileName == fTreeDFileName && fTreeSFile);
- alreadyopen2 =
- (active[2] == 1 && fTreeRFileName == fTreeDFileName && fTreeRFile);
- if(!(alreadyopen1 || alreadyopen2)){
- ptr = InitFile(fileName);
- fTreeDFile = ptr;
- }
- else {
- if(alreadyopen1){fTreeDFile = fTreeSFile; ptr = fTreeDFile;}
- if(alreadyopen2){fTreeDFile = fTreeRFile; ptr = fTreeDFile;}
- }
- if(choice[2] == 1) { fTreeRFileName = fileName; fTreeRFile = ptr;}
- }
- return ptr;
- }
+Int_t AliRun::GetEvNumber() const
+{
+//Returns number of current event
+ if (fRunLoader == 0x0)
+ {
+ Error("GetEvent","RunLoader is not set. Can not load data.");
+ return -1;
+ }
- if(oR){
- // if already active and same name with non-null ptr
- if(active[2]==1 && fileName == fTreeRFileName && fTreeRFile){
- Warning("InitTreeFile","File %s already opened",fTreeRFileName.Data());
- ptr = fTreeRFile;
- }
- else {
- // if already active with different name with non-null ptr
- if(active[2]==1 && fileName != fTreeRFileName && fTreeRFile){
- // close the active files and also the other possible files in option
- CloseTreeFile(option);
- }
- fTreeRFileName = fileName;
- alreadyopen1 =
- (active[1] == 1 && fTreeDFileName == fTreeRFileName && fTreeDFile);
- alreadyopen2 =
- (active[0]== 1 && fTreeSFileName == fTreeRFileName && fTreeSFile);
- if(!(alreadyopen1 || alreadyopen2)){
- ptr = InitFile(fileName);
- fTreeRFile = ptr;
- }
- else {
- if(alreadyopen1){fTreeRFile = fTreeDFile; ptr = fTreeRFile;}
- if(alreadyopen2){fTreeRFile = fTreeSFile; ptr = fTreeRFile;}
- }
- }
- return ptr;
- }
- return 0;
+ return fRunLoader->GetEventNumber();
}
-//_______________________________________________________________________
-void AliRun::PrintTreeFile()
+void AliRun::SetRunLoader(AliRunLoader* rloader)
{
- //
- // prints the file names and pointer associated to S,D,R trees
- //
- cout<<"===================================================\n";
- TFile *file = fTreeE->GetCurrentFile();
- TString curfilname="";
- if(file)curfilname=static_cast<TString>(file->GetName());
- cout<<" Current tree file name: "<<curfilname<<endl;
- cout<<"Pointer: "<<file<<endl;
- cout<<" Tree S File name: "<<fTreeSFileName<<endl;
- cout<<"Pointer: "<<fTreeSFile<<endl<<endl;
- cout<<" Tree D File name: "<<fTreeDFileName<<endl;
- cout<<"Pointer: "<<fTreeDFile<<endl<<endl;
- cout<<" Tree R File name: "<<fTreeRFileName<<endl;
- cout<<"Pointer: "<<fTreeRFile<<endl<<endl;
- cout<<"===================================================\n";
-}
-//_______________________________________________________________________
-void AliRun::CloseTreeFile(Option_t *option)
-{
- //
- // closes the file containing the tree specified in option
- // (S,D,R)
- //
- Bool_t oS = (strstr(option,"S")!=0);
- Bool_t oR = (strstr(option,"R")!=0);
- Bool_t oD = (strstr(option,"D")!=0);
- Bool_t none = !(oS || oR || oD);
- if(none)return;
- if(oS){
- fTreeSFileName = "";
- if(fTreeSFile){
- if(!((fTreeSFile == fTreeDFile) || (fTreeSFile == fTreeRFile)) &&
- fTreeSFile->IsOpen()){
- fTreeSFile->Close();
- delete fTreeSFile;
- }
- }
- fTreeSFile = 0;
- }
- if(oD){
- fTreeDFileName = "";
- if(fTreeDFile){
- if(!((fTreeDFile == fTreeRFile) || (fTreeDFile == fTreeSFile)) &&
- fTreeDFile->IsOpen()){
- fTreeDFile->Close();
- delete fTreeDFile;
- }
- }
- fTreeDFile = 0;
- }
- if(oR){
- fTreeRFileName = "";
- if(fTreeRFile){
- if(!((fTreeRFile == fTreeSFile) || (fTreeRFile == fTreeDFile)) &&
- fTreeRFile->IsOpen()){
- fTreeRFile->Close();
- delete fTreeRFile;
+ fRunLoader = rloader;
+ if (fRunLoader == 0x0) return;
+
+ TString evfoldname;
+ TFolder* evfold = fRunLoader->GetEventFolder();
+ if (evfold) evfoldname = evfold->GetName();
+ else Warning("SetRunLoader","Did not get Event Folder from Run Loader");
+
+ if ( fRunLoader->GetAliRun() )
+ {//if alrun already exists in folder
+ if (fRunLoader->GetAliRun() != this )
+ {//and is different than this - crash
+ Fatal("AliRun","AliRun is already in Folder and it is not this object");
+ return;//pro forma
+ }//else do nothing
+ }
+ else
+ {
+ evfold->Add(this);//Post this AliRun to Folder
+ }
+
+ TIter next(fModules);
+ AliModule *module;
+ while((module = (AliModule*)next()))
+ {
+ if (evfold) AliConfig::Instance()->Add(module,evfoldname);
+ AliDetector* detector = dynamic_cast<AliDetector*>(module);
+ if (detector)
+ {
+ AliLoader* loader = fRunLoader->GetLoader(detector);
+ if (loader == 0x0)
+ {
+ Error("SetRunLoader","Can not get loader for detector %s",detector->GetName());
+ }
+ else
+ {
+ if (GetDebug()) Info("SetRunLoader","Setting loader for detector %s",detector->GetName());
+ detector->SetLoader(loader);
+ }
}
- }
- fTreeRFile = 0;
- }
+ }
}
-//_______________________________________________________________________
-void AliRun::MakeTree(Option_t *option, TFile *file)
+void AliRun::AddModule(AliModule* mod)
{
- //
- // Create some trees in the separate file
- //
- const char *oD = strstr(option,"D");
- const char *oR = strstr(option,"R");
- const char *oS = strstr(option,"S");
-
- TDirectory *cwd = gDirectory;
- char hname[30];
-
- if (oD) {
- delete fTreeD;
- sprintf(hname,"TreeD%d",fEvent);
- file->cd();
- fTreeD = static_cast<TTree*>(file->Get("hname"));
- if (!fTreeD) {
- fTreeD = new TTree(hname,"Digits");
- fTreeD->Write(0,TObject::kOverwrite);
- }
- cwd->cd();
- }
- if (oS) {
- delete fTreeS;
- sprintf(hname,"TreeS%d",fEvent);
- file->cd();
- fTreeS = static_cast<TTree*>(file->Get("hname"));
- if (!fTreeS) {
- fTreeS = new TTree(hname,"SDigits");
- fTreeS->Write(0,TObject::kOverwrite);
- }
- cwd->cd();
- }
+ if (mod == 0x0) return;
+ if (strlen(mod->GetName()) == 0) return;
+ if (GetModuleID(mod->GetName()) >= 0) return;
+
+ if (GetDebug()) Info("AddModule","%s",mod->GetName());
+ if (fRunLoader == 0x0) AliConfig::Instance()->Add(mod);
+ else AliConfig::Instance()->Add(mod,fRunLoader->GetEventFolder()->GetName());
- if (oR) {
- delete fTreeR;
- sprintf(hname,"TreeR%d",fEvent);
- file->cd();
- fTreeR = static_cast<TTree*>(file->Get("hname"));
- if (!fTreeR) {
- fTreeR = new TTree(hname,"RecPoint");
- fTreeR->Write(0,TObject::kOverwrite);
- }
- cwd->cd();
- }
+ Modules()->Add(mod);
}