]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PHOS/AliPHOSPID.cxx
Added the option to write objects into separate files and improved the cleaning
[u/mrichter/AliRoot.git] / PHOS / AliPHOSPID.cxx
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
16 /* $Id$ */
17
18 //_________________________________________________________________________
19 //  Algorithm class for the identification of particles detected in PHOS        
20 //  base  class  of identified particle  
21 //  Why should I put meaningless comments
22 //  just to satisfy
23 //  the code checker                
24                          
25 //                  
26 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko
27
28
29 // --- ROOT system ---
30 #include "TGeometry.h"
31 #include "TDirectory.h"
32 #include "TFile.h"
33 #include "TTree.h"
34  
35 // --- Standard library ---
36 #include <iostream.h>
37 #include <stdlib.h>
38
39
40 // --- AliRoot header files ---
41 #include "AliRun.h" 
42 #include "AliPHOSPID.h"
43 #include "AliHeader.h" 
44
45 ClassImp(AliPHOSPID)
46
47 //____________________________________________________________________________
48   AliPHOSPID::AliPHOSPID():TTask("","")
49 {
50   // ctor
51   fSplitFile= 0 ; 
52
53 }
54
55
56 //____________________________________________________________________________
57 AliPHOSPID::AliPHOSPID(const char* headerFile, const char * name ):TTask(name, headerFile)
58 {
59   // ctor
60
61   fSplitFile= 0 ; 
62 }
63
64 //____________________________________________________________________________
65 AliPHOSPID::~AliPHOSPID()
66 {
67   // dtor
68         
69   fSplitFile = 0 ;
70 }
71
72 //____________________________________________________________________________
73 void AliPHOSPID::SetSplitFile(const TString splitFileName) const
74 {
75   // Diverts the Digits in a file separate from the hits file
76   
77
78   TDirectory * cwd = gDirectory ;
79   TFile * splitFile = gAlice->InitTreeFile("R",splitFileName.Data());
80   splitFile->cd() ; 
81   gAlice->Write(0, TObject::kOverwrite);
82   
83   TTree *treeE  = gAlice->TreeE();
84   if (!treeE) {
85     cerr << "ERROR: AliPHOSPID::SetSplitFile -> No TreeE found "<<endl;
86     abort() ;
87   }      
88   
89   // copy TreeE
90   AliHeader *header = new AliHeader();
91   treeE->SetBranchAddress("Header", &header);
92   treeE->SetBranchStatus("*",1);
93   TTree *treeENew =  treeE->CloneTree();
94   treeENew->Write(0, TObject::kOverwrite);
95   
96   // copy AliceGeom
97   TGeometry *AliceGeom = static_cast<TGeometry*>(cwd->Get("AliceGeom"));
98   if (!AliceGeom) {
99     cerr << "ERROR: AliPHOSPID::SetSplitFile -> AliceGeom was not found in the input file "<<endl;
100     abort() ;
101     }
102   AliceGeom->Write(0, TObject::kOverwrite) ;
103   
104   gAlice->MakeTree("R",splitFile);
105   cwd->cd() ; 
106   cout << "INFO: AliPHOSPID::SetSPlitMode -> RecParticles will be stored in " << splitFileName.Data() << endl ;   
107 }