2 //////////////////////////////////////////////////////////////////////////
4 // AliFast virtual base class for Makers //
6 //////////////////////////////////////////////////////////////////////////
11 #include <TClonesArray.h>
14 #include "AliFMaker.h"
19 //_____________________________________________________________________________
20 AliFMaker::AliFMaker()
30 //_____________________________________________________________________________
31 AliFMaker::AliFMaker(const char *name, const char *title)
36 fHistograms = new TList();
40 gAliFast->Makers()->Add(this);
43 //_____________________________________________________________________________
44 AliFMaker::~AliFMaker()
50 //______________________________________________________________________________
51 void AliFMaker::Browse(TBrowser *b)
53 // Insert Maker objects in the list of objects to browsed.
56 if( b == 0 || fFruits == 0) return;
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++) {
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]);
70 // fFruits points to an object in general. Insert this object in the browser
72 b->Add( fFruits, fFruits->GetName());
76 //_____________________________________________________________________________
77 void AliFMaker::Clear(Option_t *option)
79 if (fFruits) fFruits->Clear(option);
84 //_____________________________________________________________________________
85 void AliFMaker::Draw(Option_t *)
87 // Insert products of this maker in graphics pad list
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++) {
98 if (obj) obj->AppendPad();
100 // fFruits points to an object in general. Insert this object in the pad
102 fFruits->AppendPad();
106 //_____________________________________________________________________________
107 void AliFMaker::FillClone()
109 // Copy original fruits in a separate list (clones)
111 if (!fIsClonable || fFruits == 0) return;
112 fClones = fFruits->Clone();
115 //_____________________________________________________________________________
116 void AliFMaker::Init()
121 //_____________________________________________________________________________
122 void AliFMaker::Finish()
128 //_____________________________________________________________________________
129 void AliFMaker::Make()
132 Warning("Make","Dummy function called");
135 //_____________________________________________________________________________
136 void AliFMaker::PrintInfo()
138 printf("*************************************************************\n");
140 printf("* %25s *\n",GetName());
142 printf("*************************************************************\n");
147 //_____________________________________________________________________________
148 void AliFMaker::MakeBranch()
150 // Adds the list of physics objects to the AliFast tree as a new branch
152 if (fSave == 0) return;
154 TTree *tree = gAliFast->Tree();
155 if (tree == 0 || fFruits == 0 || fBranchName.Length() == 0) return;
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);
162 tree->Branch(fBranchName.Data(),fFruits->ClassName(), &fFruits, buffersize);
166 //_____________________________________________________________________________
167 void AliFMaker::SetChainAddress(TChain *chain)
169 // Set branch address in a chain of files
171 if (chain == 0) return;
173 chain->SetBranchAddress(fBranchName.Data(), &fFruits);
176 //______________________________________________________________________________
177 void AliFMaker::Streamer(TBuffer &R__b)
179 // Stream an object of class AliFMaker.
181 if (R__b.IsReading()) {
183 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
185 AliFMaker::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
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);
193 AliFMaker::Class()->WriteBuffer(R__b,this);