]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ALIFAST/AliFMaker.cxx
Streamlining of CodeAnalysis. .ii files are kept for reverse engineering
[u/mrichter/AliRoot.git] / ALIFAST / AliFMaker.cxx
1
2 //////////////////////////////////////////////////////////////////////////
3 //                                                                      //
4 // AliFast virtual base class for Makers                                //
5 //                                                                      //
6 //////////////////////////////////////////////////////////////////////////
7
8 #include <TChain.h>
9 #include <TTree.h>
10 #include <TList.h>
11 #include <TClonesArray.h>
12 #include <TBrowser.h>
13
14 #include "AliFMaker.h"
15 #include "AliFast.h"
16
17 ClassImp(AliFMaker)
18
19 //_____________________________________________________________________________
20 AliFMaker::AliFMaker()
21 {
22    fBranchName = "";
23    fSave       = 0;
24    fHistograms = 0;
25    fFruits     = 0;
26    fClones     = 0;
27    fIsClonable = kTRUE;
28 }
29
30 //_____________________________________________________________________________
31 AliFMaker::AliFMaker(const char *name, const char *title)
32        :TNamed(name,title)
33 {
34    fBranchName = "";
35    fSave       = 0;
36    fHistograms = new TList();
37    fClones     = 0;
38    fIsClonable = kTRUE;
39    
40    gAliFast->Makers()->Add(this);
41 }
42
43 //_____________________________________________________________________________
44 AliFMaker::~AliFMaker()
45 {
46   delete fFruits;
47   delete fClones;
48 }
49
50 //______________________________________________________________________________
51 void AliFMaker::Browse(TBrowser *b)
52 {
53 //  Insert Maker objects in the list of objects to browsed.
54
55   char name[64];
56   if( b == 0  || fFruits == 0) return;
57   TObject *obj;
58
59 // If fFruits is a ClonesArray, insert all the objects in the list
60 // of browsable objects
61   if (fFruits->InheritsFrom("TClonesArray")) {
62      TClonesArray *clones = (TClonesArray*)fFruits;
63      Int_t nobjects = clones->GetEntries();
64      for (Int_t i=0;i<nobjects;i++) {
65         obj = clones->At(i);
66         sprintf(name,"%s_%d",obj->GetName(),i);
67         if (strstr(name,"AliF")) b->Add(obj, &name[4]);
68         else                     b->Add(obj, &name[0]);
69      }
70 // fFruits points to an object in general. Insert this object in the browser
71   } else {
72       b->Add( fFruits, fFruits->GetName());
73   }
74 }
75
76 //_____________________________________________________________________________
77 void AliFMaker::Clear(Option_t *option)
78 {
79   if (fFruits) fFruits->Clear(option);
80   delete fClones;
81   fClones = 0;
82 }
83
84 //_____________________________________________________________________________
85 void AliFMaker::Draw(Option_t *)
86 {
87 //    Insert products of this maker in graphics pad list
88
89   TObject *obj;
90
91 // If fFruits is a ClonesArray, insert all the objects in the list
92 // of objects to be painted
93   if (fFruits->InheritsFrom("TClonesArray")) {
94      TClonesArray *clones = (TClonesArray*)fFruits;
95      Int_t nobjects = clones->GetEntries();
96      for (Int_t i=0;i<nobjects;i++) {
97         obj = clones->At(i);
98         if (obj) obj->AppendPad();
99      }
100 // fFruits points to an object in general. Insert this object in the pad
101   } else {
102      fFruits->AppendPad();
103   }
104 }
105
106 //_____________________________________________________________________________
107 void AliFMaker::FillClone()
108 {
109 //   Copy original fruits in a separate list (clones)
110
111    if (!fIsClonable || fFruits == 0) return;
112    fClones = fFruits->Clone();
113 }
114
115 //_____________________________________________________________________________
116 void AliFMaker::Init()
117 {
118    //dummy
119 }
120
121 //_____________________________________________________________________________
122 void AliFMaker::Finish()
123 {
124
125    //dummy
126 }
127
128 //_____________________________________________________________________________
129 void AliFMaker::Make()
130 {
131
132    Warning("Make","Dummy function called");
133 }
134
135 //_____________________________________________________________________________
136 void AliFMaker::PrintInfo()
137 {
138    printf("*************************************************************\n");
139    printf("*                                                           *\n");
140    printf("*            %25s                      *\n",GetName());
141    printf("*                                                           *\n");
142    printf("*************************************************************\n");
143
144    Dump();
145 }
146
147 //_____________________________________________________________________________
148 void AliFMaker::MakeBranch()
149 {
150 //   Adds the list of physics objects to the AliFast tree as a new branch
151
152    if (fSave == 0) return;
153
154    TTree *tree = gAliFast->Tree();
155    if (tree == 0  || fFruits == 0  || fBranchName.Length() == 0) return;
156
157 //  Make a branch tree if a branch name has been set
158    Int_t buffersize = 4000;
159    if (fFruits->InheritsFrom("TClonesArray")) {
160       tree->Branch(fBranchName.Data(), &fFruits, buffersize);
161    } else {
162       tree->Branch(fBranchName.Data(),fFruits->ClassName(), &fFruits, buffersize);
163    }
164 }
165
166 //_____________________________________________________________________________
167 void AliFMaker::SetChainAddress(TChain *chain)
168 {
169 //   Set branch address in a chain of files
170
171    if (chain == 0) return;
172
173    chain->SetBranchAddress(fBranchName.Data(), &fFruits);
174 }
175
176 //______________________________________________________________________________
177 void AliFMaker::Streamer(TBuffer &R__b)
178 {
179    // Stream an object of class AliFMaker.
180
181    if (R__b.IsReading()) {
182       R__b.ReadVersion(); // Version_t R__v = R__b.ReadVersion();
183       TNamed::Streamer(R__b);
184       R__b >> fSave;
185       R__b >> fFruits;
186       fBranchName.Streamer(R__b);
187       R__b >> fHistograms;
188           //this is an addition to the standard rootcint version of Streamer
189           //branch address for this maker is set automatically
190       TTree *tree = gAliFast->Tree();
191       if (tree == 0  || fFruits == 0  || fBranchName.Length() == 0) return;
192       TBranch *branch = tree->GetBranch(fBranchName.Data());
193       if (branch)  branch->SetAddress(&fFruits);
194    } else {
195       R__b.WriteVersion(AliFMaker::IsA());
196       TNamed::Streamer(R__b);
197       R__b << fSave;
198       R__b << fFruits;
199       fBranchName.Streamer(R__b);
200       R__b << fHistograms;
201    }
202 }
203
204
205
206
207
208
209
210
211
212
213
214
215
216