Added the option to write objects into separate files and improved the cleaning
[u/mrichter/AliRoot.git] / PHOS / AliPHOSClusterizer.cxx
CommitLineData
d15a28e7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
b2a60966 19// Base class for the clusterization algorithm (pure abstract)
baef0810 20//*--
b2a60966 21//*-- Author: Yves Schutz SUBATECH
d15a28e7 22//////////////////////////////////////////////////////////////////////////////
23
24// --- ROOT system ---
8d0f3f77 25#include "TGeometry.h"
26#include "TDirectory.h"
27#include "TFile.h"
28#include "TTree.h"
d15a28e7 29
d15a28e7 30
31// --- Standard library ---
8d0f3f77 32#include <iostream.h>
33#include <stdlib.h>
d15a28e7 34
35// --- AliRoot header files ---
8d0f3f77 36#include "AliRun.h"
d15a28e7 37#include "AliPHOSClusterizer.h"
8d0f3f77 38#include "AliHeader.h"
d15a28e7 39
40ClassImp(AliPHOSClusterizer)
41
42//____________________________________________________________________________
7b7c1533 43 AliPHOSClusterizer::AliPHOSClusterizer():TTask("","")
9a1398dd 44{
45 // ctor
8d0f3f77 46 fSplitFile= 0 ;
9a1398dd 47}
8d0f3f77 48
9a1398dd 49//____________________________________________________________________________
7b7c1533 50AliPHOSClusterizer::AliPHOSClusterizer(const char* headerFile, const char* name):
51TTask(name, headerFile)
d15a28e7 52{
53 // ctor
8d0f3f77 54 fSplitFile= 0 ;
55
d15a28e7 56}
57
58//____________________________________________________________________________
59AliPHOSClusterizer::~AliPHOSClusterizer()
60{
61 // dtor
8d0f3f77 62
63 fSplitFile = 0 ; ;
64}
65
66//____________________________________________________________________________
67void AliPHOSClusterizer::SetSplitFile(const TString splitFileName)
68{
69 // Diverts the RecPoints in a file separate from the Digits file
70
71
72 TDirectory * cwd = gDirectory ;
73 fSplitFile = gAlice->InitTreeFile("R",splitFileName.Data());
74 fSplitFile->cd() ;
75 gAlice->Write(0, TObject::kOverwrite);
76
77 TTree *treeE = gAlice->TreeE();
78 if (!treeE) {
79 cerr << "ERROR: AliPHOSClusterizer::SetSplitFile -> No TreeE found "<<endl;
80 abort() ;
81 }
82
83 // copy TreeE
84 AliHeader *header = new AliHeader();
85 treeE->SetBranchAddress("Header", &header);
86 treeE->SetBranchStatus("*",1);
87 TTree *treeENew = treeE->CloneTree();
88 treeENew->Write(0, TObject::kOverwrite);
89
90 // copy AliceGeom
91 TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
92 if (!AliceGeom) {
93 cerr << "ERROR: AliPHOSClusterizer::SetSplitFile -> AliceGeom was not found in the input file "<<endl;
94 abort() ;
95 }
96 AliceGeom->Write(0, TObject::kOverwrite);
97
98 gAlice->MakeTree("R", fSplitFile);
99 cwd->cd() ;
100 cout << "INFO: AliPHOSClusterizer::SetSPlitMode -> RecPoints will be stored in " << splitFileName.Data() << endl ;
d15a28e7 101}