1 addObjectDuringAODCreation() {
3 // add an object to an aod and write it
5 TFile *aodFile = TFile::Open("addAOD.root", "RECREATE");
7 // create an AliAOD object
8 AliAODEvent *aod = new AliAODEvent();
9 aod->CreateStdContent();
11 // add new information, we use AliESDtracks for now
12 TClonesArray *tracks = new TClonesArray("AliESDtrack", 0);
13 aod->AddObject(tracks);
19 TTree *aodTree = new TTree("aodTree", "AliAOD tree");
20 aodTree->Branch(aod->GetList());
22 for (Int_t iEvent = 0; iEvent < 10; ++iEvent) {
23 // add (part of) standard information
24 AliAODHeader *header = aod->GetHeader();
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)
30 TClonesArray &rTracks = *tracks;
31 for (Int_t i = 0; i< iEvent+5; i++) {
32 new(rTracks[i]) AliESDtrack();
35 // fill the tree for this event
37 } // end of event loop
39 aodTree->GetUserInfo()->Add(aod);
41 // write the tree to the specified file
42 aodFile = aodTree->GetCurrentFile();