/*
$Log$
+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)
//_____________________________________________________________________________
AliRun::AliRun()
+ : fParticleFileMap(fHeader.GetParticleFileMap())
{
//
// Default constructor for AliRun
fRandom = 0;
fMCQA = 0;
fTransParName = "\0";
- fBaseFileName = "\0";
+ fBaseFileName = ".\0";
fParticleBuffer = 0;
fParticleMap = new TObjArray(10000);
}
//_____________________________________________________________________________
AliRun::AliRun(const char *name, const char *title)
- : TNamed(name,title)
+ : TNamed(name,title),
+ fParticleFileMap(fHeader.GetParticleFileMap())
+
{
//
// Constructor for the main processor.
fHitLists = new TList();
//
SetTransPar();
- fBaseFileName = "\0";
+ fBaseFileName = ".\0";
fParticleBuffer = 0;
fParticleMap = new TObjArray(10000);
}
// Write out the kinematics
if (fTreeK) {
CleanParents();
- // fTreeK->Fill();
+ if(fTreeK->GetEntries() ==0) {
+ // set the fParticleFileMap size for the first time
+ if (fHgwmk+1 > fParticleFileMap.GetSize())
+ fParticleFileMap.Set(fHgwmk+1);
+ }
+ // fTreeK->Fill();
Bool_t allFilled = kFALSE;
TObject *part;
for(i=0; i<fHgwmk+1; ++i) if((part=fParticleMap->At(i))) {
if(!allFilled) allFilled = kTRUE;
}
}
+
+ // Set number of tracks to event header
+ fHeader.SetNtrack(fNtrack);
// Write out the digits
if (fTreeD) {
fTreeE->Write(0,TObject::kOverwrite);
// Write AliRun info and all detectors parameters
- Write();
+ Write(0,TObject::kOverwrite);
// Clean tree information
if (fTreeK) {
return;
}
- OpenBaseFile("recreate");
-
gROOT->LoadMacro(setup);
gInterpreter->ProcessLine(fConfigFunction.Data());
//____________________________________________________________________________
void AliRun::SetBaseFile(char *filename)
{
- fBaseFileName = *filename;
-}
-
-//____________________________________________________________________________
-void AliRun::OpenBaseFile(const char *option)
-{
- if(!strlen(fBaseFileName.Data())) {
- const char *filename;
- if ((filename=gSystem->Getenv("CONFIG_FILE"))) {
- fBaseFileName=filename;
- } else {
- fBaseFileName="galice.root";
- }
- }
- TFile *rootfile = new TFile(fBaseFileName.Data(),option);
- rootfile->SetCompressionLevel(2);
+ fBaseFileName = filename;
}
//____________________________________________________________________________
}
//_____________________________________________________________________________
-void AliRun::MakeBranchInTree(TTree *tree, const char* name, void* address, Int_t size, char *file)
+TBranch* AliRun::MakeBranchInTree(TTree *tree, const char* name, void* address, Int_t size, char *file)
{
+ //
+ // Makes branch in given tree and diverts them to a separate file
+ //
if (GetDebug()>1)
printf("* MakeBranch * Making Branch %s \n",name);
TBranch *branch = tree->Branch(name,address,size);
if (file) {
+ char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
+ sprintf(outFile,"%s/%s",gAlice->GetBaseFile(),file);
TDirectory *cwd = gDirectory;
- branch->SetFile(file);
+ branch->SetFile(outFile);
TIter next( branch->GetListOfBranches());
while ((branch=(TBranch*)next())) {
- branch->SetFile(file);
+ branch->SetFile(outFile);
}
if (GetDebug()>1)
printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
cwd->cd();
- }
+ delete outFile;
+ }
+
+ return branch;
}
//_____________________________________________________________________________
-void AliRun::MakeBranchInTree(TTree *tree, const char* name, const char *classname, void* address, Int_t size, Int_t splitlevel, char *file)
+TBranch* AliRun::MakeBranchInTree(TTree *tree, const char* name, const char *classname, void* address, Int_t size, Int_t splitlevel, char *file)
{
+ //
+ // Makes branch in given tree and diverts them to a separate file
+ //
TDirectory *cwd = gDirectory;
TBranch *branch = tree->Branch(name,classname,address,size,splitlevel);
+
if (GetDebug()>1)
printf("* MakeBranch * Making Branch %s \n",name);
if (file) {
- branch->SetFile(file);
+ char * outFile = new char[strlen(gAlice->GetBaseFile())+strlen(file)+2];
+ sprintf(outFile,"%s/%s",gAlice->GetBaseFile(),file);
+ branch->SetFile(outFile);
TIter next( branch->GetListOfBranches());
while ((branch=(TBranch*)next())) {
- branch->SetFile(file);
+ branch->SetFile(outFile);
}
if (GetDebug()>1)
printf("* MakeBranch * Diverting Branch %s to file %s\n",name,file);
cwd->cd();
+ delete outFile;
}
+ return branch;
}
//_____________________________________________________________________________
void AliRun::MakeTree(Option_t *option, char *file)
char hname[30];
//
// Analyse options
- char *oK = strstr(option,"K");
- char *oH = strstr(option,"H");
- char *oE = strstr(option,"E");
- char *oD = strstr(option,"D");
- char *oR = strstr(option,"R");
- char *oS = strstr(option,"S");
+ 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");
//
if (oK && !fTreeK) {
}
if (oE && !fTreeE) {
fTreeE = new TTree("TE","Header");
- // Create a branch for Header
- MakeBranchInTree(fTreeE,
- "Header", "AliHeader", &gAliHeader, 4000, 1, file) ;
+ TBranch* branch
+ = MakeBranchInTree(fTreeE,
+ "Header", "AliHeader", &gAliHeader, 4000, 0, file) ;
+ branch->SetAutoDelete(kFALSE);
fTreeE->Write();
}
TIter next(fModules);
AliModule *detector;
while((detector = (AliModule*)next())) {
- if (oH || oR) detector->MakeBranch(option,file);
+ if (oH) detector->MakeBranch(option,file);
}
}
{
if(!(*fParticleMap)[i]) {
Int_t nentries = fParticles->GetEntries();
+
+ // algorithmic way of getting entry index
+ // (primary particles are filled after secondaries)
+ Int_t entry;
+ if (i<fHeader.GetNprimary())
+ entry = i+fHeader.GetNsecondary();
+ else
+ entry = i-fHeader.GetNprimary();
+
+ // only check the algorithmic way and give
+ // the fatal error if it is wrong
+ if (entry != fParticleFileMap[i]) {
+ Fatal("Particle",
+ "!!!! The algorithmic way is WRONG: !!!\n entry: %d map: %d",
+ entry, fParticleFileMap[i]);
+ }
+
fTreeK->GetEntry(fParticleFileMap[i]);
+ //fTreeK->GetEntry(entry);
new ((*fParticles)[nentries]) TParticle(*fParticleBuffer);
fParticleMap->AddAt((*fParticles)[nentries],i);
}
// Create the Root Tree with one branch per detector
+ MakeTree("ESD");
+
if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
- MakeTree("E");
- MakeTree("K","Kine.root");
- MakeTree("H","Hits.root");
- MakeTree("R","Reco.root");
+ MakeTree("K","Kine.root");
+ MakeTree("H","Hits.root");
} else {
- MakeTree("EKHR");
+ MakeTree("KH");
}
gMC->ProcessRun(nevent);
if(nevent>0) FinishRun();
}
+//_____________________________________________________________________________
+void AliRun::RunReco(const char *detector)
+{
+ //
+ // Main function to be called to reconstruct Alice event
+ //
+
+ MakeTree("R");
+ Digits2Reco(detector);
+}
+
//_____________________________________________________________________________
void AliRun::Hits2Digits(const char *selected)
{
+ // Convert Hits to sumable digits
+ //
Hits2SDigits(selected);
SDigits2Digits(selected);
}
+
//_____________________________________________________________________________
-void AliRun::Hits2SDigits(const char *selected)
+void AliRun::Tree2Tree(Option_t *option, const char *selected)
{
//
- // Main function to be called to convert hits to digits.
-
- gAlice->GetEvent(0);
-
- TObjArray *detectors = gAlice->Detectors();
-
- TIter next(detectors);
-
- AliDetector *detector;
+ // 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).
- TDirectory *cwd = gDirectory;
- MakeTree("S");
+ const char *oS = strstr(option,"S");
+ const char *oD = strstr(option,"D");
+ const char *oR = strstr(option,"R");
- while((detector = (AliDetector*)next())) {
- if (selected) {
- if (strcmp(detector->GetName(),selected)) continue;
- }
- if (detector->IsActive()){
- if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
- if (GetDebug()>0)
- cout << "Processing " << detector->GetName() << "..." << endl;
- char * outFile = new char[strlen (detector->GetName())+18];
- sprintf(outFile,"SDigits.%s.root",detector->GetName());
- detector->MakeBranch("S",outFile);
- delete outFile;
- } else {
- detector->MakeBranch("S");
- }
- cwd->cd();
- detector->Hits2SDigits();
- }
- }
-}
-
-//_____________________________________________________________________________
-
-void AliRun::SDigits2Digits(const char *selected)
-{
- //
- // Main function to be called to convert hits to digits.
-
gAlice->GetEvent(0);
TObjArray *detectors = gAlice->Detectors();
TIter next(detectors);
- AliDetector *detector;
+ AliDetector *detector = 0;
TDirectory *cwd = gDirectory;
- MakeTree("D");
+ char outFile[32];
while((detector = (AliDetector*)next())) {
- if (selected) {
+ if (selected)
if (strcmp(detector->GetName(),selected)) continue;
- }
if (detector->IsActive()){
- if (gSystem->Getenv("CONFIG_SPLIT_FILE")) {
- if (GetDebug()>0)
+ if (GetDebug()>0)
cout << "Processing " << detector->GetName() << "..." << endl;
- char * outFile = new char[strlen (detector->GetName())+16];
- sprintf(outFile,"Digits.%s.root",detector->GetName());
- detector->MakeBranch("D",outFile);
- delete outFile;
+ 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("D");
- }
- cwd->cd();
- detector->SDigits2Digits();
+ detector->MakeBranch(option);
+ }
+
+ cwd->cd();
+
+ if (oS)
+ detector->Hits2SDigits();
+ if (oD)
+ detector->SDigits2Digits();
+ if (oR)
+ 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,