46          : fHistType(0), fNHists(16), fDraw(0), fHist1D(0), fHist2D(0), fHist3D(0),
 
   47            fRandom(0), fCHist1D(0), fCHist2D(0), fCHist3D(0)
 
   62    for (Int_t i=0; i < fNHists; i++) {
 
   63       if (fHist1D && fHist1D[i] && !fOutput->FindObject(fHist1D[i])) {
 
   64          SafeDelete(fHist1D[i]);
 
   66       if (fHist2D && fHist2D[i] && !fOutput->FindObject(fHist2D[i])) {
 
   67          SafeDelete(fHist2D[i]);
 
   69       if (fHist3D && fHist3D[i] && !fOutput->FindObject(fHist3D[i])) {
 
   70          SafeDelete(fHist3D[i]);
 
   84 void TSelHist::Begin(TTree * )
 
   86    TString option = GetOption();
 
   88    Bool_t found_histtype=kFALSE;
 
   89    Bool_t found_nhists=kFALSE;
 
   90    Bool_t found_draw=kFALSE;
 
   97    while ((obj = nxt())){
 
   98       sinput=obj->GetName();
 
  100       if (sinput.Contains(
"PROOF_Benchmark_HistType")){
 
  101          if ((fHistType = dynamic_cast<TPBHistType *>(obj))) found_histtype = kTRUE;
 
  104       if (sinput.Contains(
"PROOF_BenchmarkNHists")){
 
  105          TParameter<Int_t>* a=
dynamic_cast<TParameter<Int_t>*
>(obj);
 
  107             fNHists= a->GetVal();
 
  112             Error(
"Begin", 
"PROOF_BenchmarkNHists not type TParameter<Int_t>*");
 
  116       if (sinput.Contains(
"PROOF_BenchmarkDraw")){
 
  117          TParameter<Int_t>* a=
dynamic_cast<TParameter<Int_t>*
>(obj);
 
  124             Error(
"Begin", 
"PROOF_BenchmarkDraw not type TParameter<Int_t>*");
 
  130    if (!found_histtype){
 
  131       fHistType = 
new TPBHistType(TPBHistType::kHist1D);
 
  132       Warning(
"Begin", 
"PROOF_Benchmark_HistType not found; using default: %d",
 
  133                        (Int_t) fHistType->GetType());
 
  136       Warning(
"Begin", 
"PROOF_BenchmarkNHists not found; using default: %d",
 
  140       Warning(
"Begin", 
"PROOF_BenchmarkDraw not found; using default: %d",
 
  145       if (fHistType->GetType() & TPBHistType::kHist1D) fHist1D = 
new TH1F*[fNHists];
 
  146       if (fHistType->GetType() & TPBHistType::kHist2D) fHist2D = 
new TH2F*[fNHists];
 
  147       if (fHistType->GetType() & TPBHistType::kHist3D) fHist3D = 
new TH3F*[fNHists];
 
  156 void TSelHist::SlaveBegin(TTree * )
 
  158    TString option = GetOption();
 
  160    Bool_t found_histtype=kFALSE;
 
  161    Bool_t found_nhists=kFALSE;
 
  162    Bool_t found_draw=kFALSE;
 
  168    while ((obj = nxt())){
 
  169       sinput=obj->GetName();
 
  171       if (sinput.Contains(
"PROOF_Benchmark_HistType")){
 
  172          if ((fHistType = dynamic_cast<TPBHistType *>(obj))) found_histtype = kTRUE;
 
  175       if (sinput.Contains(
"PROOF_BenchmarkNHists")){
 
  176          TParameter<Int_t>* a=
dynamic_cast<TParameter<Int_t>*
>(obj);
 
  183             Error(
"SlaveBegin", 
"PROOF_BenchmarkNHists not type TParameter" 
  188       if (sinput.Contains(
"PROOF_BenchmarkDraw")){
 
  189          TParameter<Int_t>* a=
dynamic_cast<TParameter<Int_t>*
>(obj);
 
  196             Error(
"SlaveBegin", 
"PROOF_BenchmarkDraw not type TParameter" 
  203    if (!found_histtype){
 
  204       fHistType = 
new TPBHistType(TPBHistType::kHist1D);
 
  205       Warning(
"SlaveBegin", 
"PROOF_Benchmark_HistType not found; using default: %d",
 
  206                        fHistType->GetType());
 
  209       Warning(
"SlaveBegin", 
"PROOF_BenchmarkNHists not found; using default: %d",
 
  213       Warning(
"SlaveBegin", 
"PROOF_BenchmarkDraw not found; using default: %d",
 
  218    if (fHistType->GetType() & TPBHistType::kHist1D){
 
  219       fHist1D = 
new TH1F*[fNHists];
 
  220       for (Int_t i=0; i < fNHists; i++) {
 
  221          fHist1D[i] = 
new TH1F(Form(
"h1d_%d",i), Form(
"h1d_%d",i), 100, -3., 3.);
 
  222          fHist1D[i]->SetFillColor(kRed);
 
  223          if (fDraw) fOutput->Add(fHist1D[i]);
 
  226    if (fHistType->GetType() & TPBHistType::kHist2D){
 
  227       fHist2D = 
new TH2F*[fNHists];
 
  228       for (Int_t i=0; i < fNHists; i++) {
 
  229          fHist2D[i] = 
new TH2F(Form(
"h2d_%d",i), Form(
"h2d_%d",i), 100, -3., 3.,
 
  231          fHist2D[i]->SetFillColor(kRed);
 
  232          if (fDraw) fOutput->Add(fHist2D[i]);
 
  235    if (fHistType->GetType() & TPBHistType::kHist3D){
 
  236       fHist3D = 
new TH3F*[fNHists];
 
  237       for (Int_t i=0; i < fNHists; i++) {
 
  238          fHist3D[i] = 
new TH3F(Form(
"h3d_%d",i), Form(
"h3d_%d",i), 100, -3., 3.,
 
  239                                100, -3., 3., 100, -3., 3.);
 
  240          fHist3D[i]->SetFillColor(kRed);
 
  241          if (fDraw) fOutput->Add(fHist3D[i]);
 
  245    fRandom = 
new TRandom3(0);
 
  267 Bool_t TSelHist::Process(Long64_t)
 
  270    if (fHistType->GetType() & TPBHistType::kHist1D){
 
  271       for (Int_t i=0; i < fNHists; i++) {
 
  272          if (fRandom && fHist1D[i]) {
 
  273             x = fRandom->Gaus(0.,1.);
 
  278    if (fHistType->GetType() & TPBHistType::kHist2D){
 
  279       for (Int_t i=0; i < fNHists; i++) {
 
  280          if (fRandom && fHist2D[i]) {
 
  281             x = fRandom->Gaus(0.,1.);
 
  282             y = fRandom->Gaus(0.,1.);
 
  283             fHist2D[i]->Fill(x, y);
 
  287    if (fHistType->GetType() & TPBHistType::kHist3D){
 
  288       for (Int_t i=0; i < fNHists; i++) {
 
  289          if (fRandom && fHist3D[i]) {
 
  290             x = fRandom->Gaus(0.,1.);
 
  291             y = fRandom->Gaus(0.,1.);
 
  292             z = fRandom->Gaus(0.,1.);
 
  293             fHist3D[i]->Fill(x, y, z);
 
  306 void TSelHist::SlaveTerminate()
 
  315 void TSelHist::Terminate()
 
  321    if (!fDraw || gROOT->IsBatch()){
 
  325    if (fHistType->GetType() & TPBHistType::kHist1D){
 
  326       fCHist1D=
dynamic_cast<TCanvas*
>(gROOT->FindObject(
"CHist1D"));
 
  328          fCHist1D = 
new TCanvas(
"CHist1D",
"Proof TSelHist Canvas (1D)", 200, 10,
 
  330          Int_t nside = (Int_t)TMath::Sqrt((Float_t)fNHists);
 
  331          nside = (nside*nside < fNHists) ? nside+1 : nside;
 
  332          fCHist1D->Divide(nside,nside,0,0);
 
  335       for (Int_t i=0; i < fNHists; i++) {
 
  336          fHist1D[i] = 
dynamic_cast<TH1F *
> 
  337                                 (fOutput->FindObject(Form(
"h1d_%d",i)));
 
  339          if (fHist1D[i]) fHist1D[i]->Draw();
 
  345    if (fHistType->GetType() & TPBHistType::kHist2D){
 
  346       fCHist2D=
dynamic_cast<TCanvas*
>(gROOT->FindObject(
"CHist2D"));
 
  348          fCHist2D = 
new TCanvas(
"CHist2D",
"Proof TSelHist Canvas (2D)", 200, 10,
 
  350          Int_t nside = (Int_t)TMath::Sqrt((Float_t)fNHists);
 
  351          nside = (nside*nside < fNHists) ? nside+1 : nside;
 
  352          fCHist2D->Divide(nside,nside,0,0);
 
  354       for (Int_t i=0; i < fNHists; i++) {
 
  355          fHist2D[i] = 
dynamic_cast<TH2F *
> 
  356                                         (fOutput->FindObject(Form(
"h2d_%d",i)));
 
  358          if (fHist2D[i]) fHist2D[i]->Draw(
"SURF");
 
  365    if (fHistType->GetType() & TPBHistType::kHist3D){
 
  366       fCHist3D=
dynamic_cast<TCanvas*
>(gROOT->FindObject(
"CHist3D"));
 
  368          fCHist3D = 
new TCanvas(
"CHist3D",
"Proof TSelHist Canvas (3D)", 200, 10,
 
  370          Int_t nside = (Int_t)TMath::Sqrt((Float_t)fNHists);
 
  371          nside = (nside*nside < fNHists) ? nside+1 : nside;
 
  372          fCHist3D->Divide(nside,nside,0,0);
 
  376       for (Int_t i=0; i < fNHists; i++) {
 
  377          fHist3D[i] = 
dynamic_cast<TH3F *
> 
  378                                         (fOutput->FindObject(Form(
"h3d_%d",i)));
 
  380       if (fHist3D[i]) printf(
"fHist3D[%d] found\n", i);
 
  381          if (fHist3D[i]) fHist3D[i]->Draw();