]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ANALYSIS/AliReaderAOD.cxx
ReaderESDtree, MUON analysis, reading MUON data froESD in ReaderESD (Christian FINCK)
[u/mrichter/AliRoot.git] / ANALYSIS / AliReaderAOD.cxx
CommitLineData
dd2b6810 1#include "AliReaderAOD.h"
2
3ClassImp(AliReaderAOD)
4
5#include <TError.h>
6#include <TFile.h>
7#include <TTree.h>
8#include "AliAOD.h"
9
beb1c41d 10Int_t AliReaderAOD::WriteAOD(AliReader* reader, const char* outfilename, const char* pclassname, Bool_t /*multcheck*/)
dd2b6810 11{
12//reads tracks from runs and writes them to file
13 ::Info("AliReaderAOD::Write","________________________________________________________");
14 ::Info("AliReaderAOD::Write","________________________________________________________");
15 ::Info("AliReaderAOD::Write","________________________________________________________");
16
17 if (reader == 0x0)
18 {
19 ::Error("AliReaderAOD::Write","Input Reader is NULL");
20 return -1;
21 }
22 TFile *outfile = TFile::Open(outfilename,"recreate");
23 if (outfile == 0x0)
24 {
25 ::Error("AliReaderAOD::Write","Can not open output file %s",outfilename);
26 return -1;
27 }
28
29 TTree *tree = new TTree("TAOD","Tree with tracks");
30
31 TBranch *recbranch = 0x0, *simbranch = 0x0;
dd2b6810 32
dd2b6810 33
beb1c41d 34 AliAOD* eventrec = new AliAOD();//must be created before Branch is called. Otherwise clones array is not splitted
35 AliAOD* eventsim = new AliAOD();//AOD together with fParticles clones array knowing exact type of particles
36
37 eventrec->SetParticleClassName(pclassname);
38 eventsim->SetParticleClassName(pclassname);
39
dd2b6810 40 if (reader->ReadsRec()) recbranch = tree->Branch("reconstructed","AliAOD",&eventrec,32000,99);
beb1c41d 41 if (reader->ReadsSim()) simbranch = tree->Branch("simulated","AliAOD",&eventsim,32000,99);
dd2b6810 42
beb1c41d 43 delete eventsim;
44 delete eventrec;
45
dd2b6810 46 reader->Rewind();
47 while (reader->Next() == kFALSE)
48 {
49
dd2b6810 50 if (reader->ReadsRec())
51 {
52 eventrec = reader->GetEventRec();
beb1c41d 53 recbranch->SetAddress(&eventrec);
54 }
55
56 if (reader->ReadsSim())
57 {
58 eventsim = reader->GetEventSim();
59 simbranch->SetAddress(&eventsim);
dd2b6810 60 }
beb1c41d 61 eventrec->GetParticle(0)->Print();
62 eventsim->GetParticle(0)->Print();
dd2b6810 63 tree->Fill();
dd2b6810 64 }
65
66 ::Info("AliReaderAOD::Write","Written %d events",tree->GetEntries());
67 outfile->cd();
68 tree->Write();
69 delete tree;
70 delete outfile;
71 return 0;
72}
73