Exemple #1
0
addObjectDuringAODCreation() {

  // add an object to an aod and write it

  TFile *aodFile = TFile::Open("addAOD.root", "RECREATE");

    // create an IlcAOD object 
  IlcAODEvent *aod = new IlcAODEvent();
  aod->CreateStdContent();
  
  // add new information, we use IlcESDtracks for now
  TClonesArray *tracks = new TClonesArray("IlcESDtrack", 0);
  aod->AddObject(tracks);

  // go to the file
  aodFile->cd();
  
  // create the tree
  TTree *aodTree = new TTree("aodTree", "IlcAOD tree");
  aodTree->Branch(aod->GetList());

  for (Int_t iEvent = 0; iEvent < 10; ++iEvent) {
    // add (part of) standard information
    IlcAODHeader *header = aod->GetHeader();

    tracks->Delete(); // delete old objects
    tracks->Expand(iEvent+5/* just to make it a different number each time*/); // expand container (just for speed)
    
    // fill TClonesArray
    TClonesArray &rTracks = *tracks;
    for (Int_t i = 0; i< iEvent+5; i++) {
      new(rTracks[i]) IlcESDtrack();
    }

    // fill the tree for this event
    aodTree->Fill();
  } // end of event loop

  aodTree->GetUserInfo()->Add(aod);

  // write the tree to the specified file
  aodFile = aodTree->GetCurrentFile();
  aodFile->cd();
  aodTree->Write();



}