This can be written as:
// The next line will:
// a. The load the proper file if mainTree or sideTree are TChain
// b. Set the cursor ( `ReadEntry` ) for both the main tree and the side tree
// (using the information from the TTreeIndex).
// c. does NOT bring into memory the data from any of branches ( `TBranch::GetEntry` needs to be called next).
Long64_t localentry = mainTree->LoadTree(5);
// Then you can load the data with:
mainTreeBranch->GetEntry(localentry);
sideTreeBranch->GetEntry( sideTreeBranch->GetTree()->GetReadEntry() ) ;