Selector to fill a set of histograms.
#define ProofSimple_cxx
#include <TFormula.h>
ProofSimple::ProofSimple()
{
fNhist = -1;
fHist = 0;
fNhist3 = -1;
fHist3 = 0;
fRandom = 0;
fHLab = 0;
fFile = 0;
fProofFile = 0;
fNtp = 0;
fHasNtuple = 0;
}
ProofSimple::~ProofSimple()
{
if (fFile) {
}
}
{
if (fInput->FindObject("ProofSimple_NHist")) {
}
else if ((iopt = option.
Index(
"nhist=")) !=
kNPOS) {
Ssiz_t from = iopt + strlen(
"nhist=");
}
if (fNhist < 1) {
Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\","
" (Long_t) <nhist>)", kAbortProcess);
return;
}
if (fInput->FindObject("ProofSimple_NHist3")) {
}
else if ((iopt = option.
Index(
"nhist3=")) !=
kNPOS) {
Ssiz_t from = iopt + strlen(
"nhist3=");
}
TNamed *nm =
dynamic_cast<TNamed *
>(fInput->FindObject(
"ProofSimple_Ntuple"));
if (nm) {
fHasNtuple = 1;
if (ontp.Contains("|plot") || ontp == "plot") {
ontp.ReplaceAll("|plot", "");
if (ontp == "plot") ontp = "";
}
if (ontp.BeginsWith("dataset")) fHasNtuple = 2;
}
}
void ProofSimple::SlaveBegin(
TTree * )
{
if (fInput->FindObject("ProofSimple_NHist")) {
}
else if ((iopt = option.
Index(
"nhist=")) !=
kNPOS) {
Ssiz_t from = iopt + strlen(
"nhist=");
}
if (fNhist < 1) {
Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\","
" (Long_t) <nhist>)", kAbortProcess);
return;
}
fHist =
new TH1F*[fNhist];
for (
Int_t i=0; i < fNhist; i++) {
fOutput->Add(fHist[i]);
}
if (fInput->FindObject("ProofSimple_NHist3")) {
}
else if ((iopt = option.
Index(
"nhist3=")) !=
kNPOS) {
Ssiz_t from = iopt + strlen(
"nhist3=");
}
if (fNhist3 > 0) {
fHist3 =
new TH3F*[fNhist3];
Info(
"Begin",
"%d 3D histograms requested", fNhist3);
for (
Int_t i=0; i < fNhist3; i++) {
100, -3., 3., 100, -3., 3., 100, -3., 3.);
fOutput->Add(fHist3[i]);
}
}
if (fInput->FindObject("ProofSimple_TestLabelMerging")) {
fHLab =
new TH1F(
"hlab",
"Test merging of histograms with automatic labels", 10, 0., 10.);
fOutput->Add(fHLab);
}
TNamed *nm =
dynamic_cast<TNamed *
>(fInput->FindObject(
"ProofSimple_Ntuple"));
if (nm) {
fHasNtuple = 1;
if (ontp.Contains("|plot") || ontp == "plot") {
ontp.ReplaceAll("|plot", "");
if (ontp == "plot") ontp = "";
}
TString locfn(
"SimpleNtuple.root");
if (ontp.BeginsWith("merge")) {
ontp.Replace(0,5,"");
fProofFile->SetRetrieve(
kTRUE);
if ((iret = ontp.Index(
"|retrieve=")) !=
kNPOS) {
rettag += "=";
fn = ontp(iret + rettag.Length(), ontp.Length() - iret - rettag.Length());
rettag += fn;
}
}
if (iof !=
kNPOS) ontp.Remove(0, iof + 1);
if (!ontp.IsNull()) {
fProofFile->SetOutputFileName(ontp.Data());
}
fProofFile->SetTitle(fn);
} else if (ontp.BeginsWith("dataset")) {
if (iof !=
kNPOS) ontp.Remove(0, iof + 1);
TString dsname = (!ontp.IsNull()) ? ontp.
Data() :
"dataset_ntuple";
fHasNtuple = 2;
} else if (!ontp.IsNull()) {
Warning(
"SlaveBegin",
"ntuple options unknown: ignored (%s)", ontp.Data());
}
if (fProofFile) {
fFile = fProofFile->OpenFile("RECREATE");
if (fFile && fFile->IsZombie())
SafeDelete(fFile);
if (!fFile) {
Info(
"SlaveBegin",
"could not create '%s': instance is invalid!", fProofFile->GetName());
return;
}
}
fNtp =
new TNtuple(
"ntuple",
"Demo ntuple",
"px:py:pz:random:i");
if (fFile) {
fNtp->SetDirectory(fFile);
fNtp->AutoSave();
} else {
fOutput->Add(fNtp);
}
}
}
{
for (
Int_t i=0; i < fNhist; i++) {
if (fRandom && fHist[i]) {
}
}
for (
Int_t i=0; i < fNhist3; i++) {
if (fRandom && fHist3[i]) {
fHist3[i]->Fill(x,x,x);
}
}
if (fHLab && fRandom) {
fRandom->RndmArray(10, rr);
for (
Int_t i=0; i < 10; i++) {
}
}
}
if (fNtp) FillNtuple(entry);
}
void ProofSimple::FillNtuple(
Long64_t entry)
{
if (!fNtp) return;
if (fRandom) {
fRandom->Rannor(px,py);
random = fRandom->Rndm();
} else {
Abort("no way to get random numbers! Stop processing", kAbortProcess);
return;
}
fNtp->Fill(px,py,pz,random,i);
return;
}
void ProofSimple::SlaveTerminate()
{
if (fFile) {
if (!fNtp) {
Error(
"SlaveTerminate",
"'ntuple' is undefined!");
return;
}
if (fNtp->GetEntries() > 0) {
fFile->cd();
fNtp->Write();
fProofFile->Print();
fOutput->Add(fProofFile);
} else {
}
fNtp->SetDirectory(0);
if (cleanup) {
TUrl uf(*(fFile->GetEndpointUrl()));
}
}
}
void ProofSimple::Terminate()
{
if (c1) {
}
c1 =
new TCanvas(
"c1",
"Proof ProofSimple canvas",200,10,700,700);
nside = (nside*nside < fNhist) ? nside+1 : nside;
for (
Int_t i=0; i < fNhist; i++) {
break;
}
}
if (tryfc && GetHistosFromFC(c1) != 0) {
Warning(
"Terminate",
"histograms not found");
} else {
}
if (fHLab && !
gROOT->IsBatch()) {
Int_t nb = fHLab->GetNbinsX();
if (nb > 0) {
Double_t entb = fHLab->GetEntries() / nb;
if (entb) {
for (
Int_t i = 0; i < nb; i++) {
Int_t ib = fHLab->GetXaxis()->FindBin(lab);
Info(
"Terminate",
" %s [%d]:\t%f", lab.
Data(), ib, fHLab->GetBinContent(ib)/entb);
}
} else
Warning(
"Terminate",
"no entries in the hlab histogram!");
}
}
if (fHasNtuple != 1 || !fPlotNtuple) return;
if ((fProofFile =
dynamic_cast<TProofOutputFile*>(fOutput->FindObject("SimpleNtuple.root")))) {
TString outputFile(fProofFile->GetOutputFileName());
TString outputName(fProofFile->GetName());
outputName += ".root";
Printf(
"outputFile: %s", outputFile.Data());
if (fFile) {
Printf(
"Managed to open file: %s", outputFile.Data());
fNtp = (
TNtuple *) fFile->Get(
"ntuple");
} else {
Error(
"Terminate",
"could not open file: %s", outputFile.Data());
}
if (!fFile) return;
} else {
Error(
"Terminate",
"TProofOutputFile not found");
return;
}
}
if (fNtp) PlotNtuple(fNtp, "proof ntuple");
}
void ProofSimple::PlotNtuple(
TNtuple *ntp,
const char *ntptitle)
{
ntp->
Draw(
"3*px+2",
"px**2+py**2>1");
ntp->
Draw(
"2*px+2",
"pz>2",
"same");
ntp->
Draw(
"1.3*px+2",
"(px^2+py^2>4) && py>0",
"same");
ntp->
Draw(
"pz:py:px",
"(pz<10 && pz>6)+(pz<4 && pz>3)");
ntp->
Draw(
"pz:py:px",
"pz<6 && pz>4",
"same");
ntp->
Draw(
"pz:py:px",
"pz<4 && pz>3",
"same");
l2->
AddText(
"You can interactively rotate this view in 2 ways:");
l2->
AddText(
" - With the RotateCube in clicking in this pad");
l2->
AddText(
" - Selecting View with x3d in the View menu");
}
{
if (strcmp(fc->
ClassName(),
"TFileCollection"))
continue;
if (!fHist) {
fHist =
new TH1F*[fNhist];
for (
Int_t i = 0; i < fNhist; i++) { fHist[i] = 0; }
} else {
}
if (f) {
for (
Int_t i = 0; i < fNhist; i++) {
if (h) {
if (!fHist[i]) {
} else {
}
} else {
Error(
"GetHistosFromFC",
"histo '%s' not found in file '%s'",
hn.
Data(), fi->GetCurrentUrl()->GetUrl());
}
}
} else {
Error(
"GetHistosFromFC",
"file '%s' could not be open", fi->GetCurrentUrl()->GetUrl());
}
}
if (hs_found) break;
}
if (!fc_found) return -1;
if (!hs_found) return -1;
for (
Int_t i = 0; i < fNhist; i++) {
if (fHist[i]) {
}
}
Info(
"GetHistosFromFC",
"histograms read from %d files in TFileCollection '%s'",
return 0;
}