]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/addObjectDuringAODCreation.C
make AliVVfriendEvent abstract (=0)
[u/mrichter/AliRoot.git] / STEER / addObjectDuringAODCreation.C
1 addObjectDuringAODCreation() {
2
3   // add an object to an aod and write it
4
5   TFile *aodFile = TFile::Open("addAOD.root", "RECREATE");
6
7     // create an AliAOD object 
8   AliAODEvent *aod = new AliAODEvent();
9   aod->CreateStdContent();
10   
11   // add new information, we use AliESDtracks for now
12   TClonesArray *tracks = new TClonesArray("AliESDtrack", 0);
13   aod->AddObject(tracks);
14
15   // go to the file
16   aodFile->cd();
17   
18   // create the tree
19   TTree *aodTree = new TTree("aodTree", "AliAOD tree");
20   aodTree->Branch(aod->GetList());
21
22   for (Int_t iEvent = 0; iEvent < 10; ++iEvent) {
23     // add (part of) standard information
24     AliAODHeader *header = aod->GetHeader();
25
26     tracks->Delete(); // delete old objects
27     tracks->Expand(iEvent+5/* just to make it a different number each time*/); // expand container (just for speed)
28     
29     // fill TClonesArray
30     TClonesArray &rTracks = *tracks;
31     for (Int_t i = 0; i< iEvent+5; i++) {
32       new(rTracks[i]) AliESDtrack();
33     }
34
35     // fill the tree for this event
36     aodTree->Fill();
37   } // end of event loop
38
39   aodTree->GetUserInfo()->Add(aod);
40
41   // write the tree to the specified file
42   aodFile = aodTree->GetCurrentFile();
43   aodFile->cd();
44   aodTree->Write();
45
46
47
48 }