A task can now declare the list of input branches that are requested during analysis.
The way to do this is to add in the constructor where the output slots are defined:
fBranchNames = "ESD:bre1,bre2,...,breN AOD:bra1,bra2,...,braM";
The declared branches are currently not loaded automatically, the list being only used to make sure we don't combine in a train tasks that are using the branch loading feature with others that expect the full event.
A task using this should manually request loading of needed branches during UserExec - see example below.
This commit modifies the AliPhysicsSelectionTask to use this feature, gaining a factor of 2 in speed when run standalone.
//________________________________________________________________________
AliAnalysisTaskPt::AliAnalysisTaskPt(const char *name)
: AliAnalysisTaskSE(name), fEvent(0), fOutputList(0), fHistPt(0)
{
// Constructor
// Define input and output slots here
// Input slot #0 works with a TChain
DefineInput(0, TChain::Class());
// Output slot #0 id reserved by the base class for AOD
// Output slot #1 writes into a TH1 container
DefineOutput(1, TList::Class());
fBranchNames = "ESD:AliESDRun.,AliESDHeader.,Tracks";
}
//________________________________________________________________________
void AliAnalysisTaskPt::UserExec(Option_t *)
{
// Main loop
// Called for each event
// Post output data.
fEvent = InputEvent();
if (!fEvent) {
printf("ERROR: Event not available\n");
return;
}
// Track loop to fill a pT spectrum.
am->LoadBranch("Tracks");
Int_t ntracks = fEvent->GetNumberOfTracks();
printf("There are %d tracks in this event\n", ntracks);
for (Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
...
}