]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ALIFAST/AliFMaker.cxx
Slats mapping files in NonBending
[u/mrichter/AliRoot.git] / ALIFAST / AliFMaker.cxx
CommitLineData
65a39007 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
17ClassImp(AliFMaker)
18
19//_____________________________________________________________________________
20AliFMaker::AliFMaker()
21{
22 fBranchName = "";
23 fSave = 0;
24 fHistograms = 0;
25 fFruits = 0;
26 fClones = 0;
27 fIsClonable = kTRUE;
28}
29
30//_____________________________________________________________________________
31AliFMaker::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//_____________________________________________________________________________
44AliFMaker::~AliFMaker()
45{
46 delete fFruits;
47 delete fClones;
48}
49
50//______________________________________________________________________________
51void 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//_____________________________________________________________________________
77void AliFMaker::Clear(Option_t *option)
78{
79 if (fFruits) fFruits->Clear(option);
80 delete fClones;
81 fClones = 0;
82}
83
84//_____________________________________________________________________________
85void 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//_____________________________________________________________________________
107void 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//_____________________________________________________________________________
116void AliFMaker::Init()
117{
118 //dummy
119}
120
121//_____________________________________________________________________________
122void AliFMaker::Finish()
123{
124
125 //dummy
126}
127
128//_____________________________________________________________________________
129void AliFMaker::Make()
130{
131
132 Warning("Make","Dummy function called");
133}
134
135//_____________________________________________________________________________
136void 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//_____________________________________________________________________________
148void 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//_____________________________________________________________________________
167void 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//______________________________________________________________________________
177void AliFMaker::Streamer(TBuffer &R__b)
178{
179 // Stream an object of class AliFMaker.
180
181 if (R__b.IsReading()) {
a8a6107b 182 UInt_t R__s, R__c;
183 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
184
185 AliFMaker::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
65a39007 186 //this is an addition to the standard rootcint version of Streamer
187 //branch address for this maker is set automatically
188 TTree *tree = gAliFast->Tree();
189 if (tree == 0 || fFruits == 0 || fBranchName.Length() == 0) return;
190 TBranch *branch = tree->GetBranch(fBranchName.Data());
191 if (branch) branch->SetAddress(&fFruits);
192 } else {
a8a6107b 193 AliFMaker::Class()->WriteBuffer(R__b,this);
65a39007 194 }
195}
196
197
198
199
200
201
202
203
204
205
206
207
208
209