All of the events in my analysis tree are weighted. So when I create histograms, I need to populate a histogram with weighted events.
[code]
Long64_t eventsSelected = tree->Draw(fieldList, cuts );
Double_t *events, *weights;
if( 0 < eventsSelected){
events = tree->GetV1();
weights = tree->GetV2();
}
for(int i=0; i<eventsSelected; ++i){
hist->Fill( events[i], weights[i] ) ;
}
//delete []events;
//delete []weights;
this->deleteHistogramFromRoot(tmpHistName);
return hist;[/code]
This method is OK but the trouble is if I try to explicitly delete the arrays returned by GetV1() then my code crashes. If I don’t delete them, my code seems to leak memory.
If I call tree->GetV1() do I need to delete the array to avoid leaking memory?