]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALLoader.cxx
6074f07dbf8ed42bf227903fbf608a062e2d5a58
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALLoader.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 //  A singleton. This class should be used in the analysis stage to get 
20 //  reconstructed objects: Digits, RecPoints, TrackSegments and RecParticles,
21 //  instead of directly reading them from galice.root file. 
22 //                  
23 //  MvL Feb 2006:
24 //  The AliEMCALLoader now holds the TClonesArray and TObjArray for reading
25 //  Hits, Dgits, SDigits and RecPoints. Filling is managed in the GetEvent()
26 //  method.
27 //
28 //  Creation/writing of files is managed by the relevant parts of the 
29 //  reconstruction software (AliEMCALDigitiser etx)
30 //
31 //*-- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC KI & SUBATECH)
32 //*--         Completely redesigned by Dmitri Peressounko March 2001  
33 //
34 //*-- YS June 2001 : renamed the original AliEMCALIndexToObject and make
35 //*--         systematic usage of TFolders without changing the interface
36 // 
37 //*-- Marco van Leeuwen, Jan 2006: complete revision to simplify reading
38 //*--         and fit better in general ALICE scheme
39 //
40 //////////////////////////////////////////////////////////////////////////////
41
42
43 // --- ROOT system ---
44
45 #include "TTree.h"
46
47 // --- Standard library ---
48
49 // --- AliRoot header files ---
50 #include "AliEMCALLoader.h"
51 #include "AliLog.h"
52
53 ClassImp(AliEMCALLoader)
54   
55 const TString AliEMCALLoader::fgkECARecPointsBranchName("EMCALECARP");//Name for branch with ECA Reconstructed Points
56
57 //____________________________________________________________________________ 
58 AliEMCALLoader::AliEMCALLoader()
59 {
60   fDebug = 0;
61   fHits = new TClonesArray("AliEMCALHit");
62   fDigits = new TClonesArray("AliEMCALDigit");
63   fSDigits = new TClonesArray("AliEMCALDigit");
64   fRecPoints = new TObjArray();
65 }
66
67 //____________________________________________________________________________ 
68 AliEMCALLoader::AliEMCALLoader(const Char_t *detname,const Char_t *eventfoldername):
69   AliLoader(detname,eventfoldername)
70 {
71   fDebug=0;
72   fHits = new TClonesArray("AliEMCALHit");
73   fDigits = new TClonesArray("AliEMCALDigit");
74   fSDigits = new TClonesArray("AliEMCALDigit");
75   fRecPoints = new TObjArray();
76 }
77
78 //____________________________________________________________________________ 
79 AliEMCALLoader::~AliEMCALLoader()
80 {
81   // Disconnect trees and remove arrays
82   if (TreeH())
83     TreeH()->SetBranchAddress(fDetectorName,0);
84   if (TreeD())
85     TreeD()->SetBranchAddress(fDetectorName,0);
86   if (TreeS())
87     TreeS()->SetBranchAddress(fDetectorName,0);
88   if (TreeR())
89     TreeR()->SetBranchAddress(fgkECARecPointsBranchName,0);
90   delete fHits;
91   delete fDigits;
92   delete fSDigits;
93   delete fRecPoints;
94 }
95
96 //____________________________________________________________________________ 
97 Int_t AliEMCALLoader::GetEvent() {
98   AliLoader::GetEvent();  // First call AliLoader to do all the groundwork
99
100   AliDebug(1,__PRETTY_FUNCTION__);
101   // Now connect and fill TClonesArray
102
103   // Hits
104   TTree *treeH = TreeH();
105   if (treeH) {
106     treeH->SetBranchAddress(fDetectorName,&fHits);
107     if (treeH->GetEntries() > 1)
108       Warning(__PRETTY_FUNCTION__,"multiple arrays in treeH no longer supported");
109     treeH->GetEvent(0);
110   }
111
112   // SDigits
113   TTree *treeS = TreeS();
114   if (treeS) {
115     treeS->SetBranchAddress(fDetectorName,&fSDigits);
116     treeS->GetEvent(0);
117   }
118
119   // Digits
120   TTree *treeD = TreeD();
121   if (treeD) {
122     treeD->SetBranchAddress(fDetectorName,&fDigits);
123     treeD->GetEvent(0);
124   }
125
126   // RecPoints
127   TTree *treeR = TreeR();
128   if (treeR) {
129     treeR->SetBranchAddress(fgkECARecPointsBranchName,&fRecPoints);
130     treeR->GetEvent(0);
131   }
132
133   return 0;
134 }