Selector to fill a simple ntuple.
#define ProofNtuple_cxx
ProofNtuple::~ProofNtuple()
{
}
void ProofNtuple::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 (out) fPlotNtuple =
kFALSE;
}
void ProofNtuple::SlaveBegin(
TTree * )
{
TNamed *nm =
dynamic_cast<TNamed *
>(fInput->FindObject(
"SimpleNtuple.root"));
if (nm) {
} else {
Info(
"SlaveBegin",
"PROOF_OUTPUTFILE_LOCATION: %s", (out ? out->
GetTitle() :
"undef"));
if (out) fProofFile->SetOutputFileName(out->
GetTitle());
}
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");
fNtp->SetDirectory(fFile);
fNtp->AutoSave();
fNtp2 =
new TNtuple(
"ntuple2",
"Demo ntuple2",
"vx:vy:vz");
fNtp2->SetDirectory(fFile);
fNtp2->AutoSave();
if (unr) {
if (!(fNtpRndm = dynamic_cast<TNtuple *>(fInput->FindObject("NtpRndm")))) {
"asked to use rndm ntuple but 'NtpRndm' not found in the"
" input list! Using the random generator");
fInput->Print();
} else {
Info(
"SlaveBegin",
"taking randoms from input ntuple 'NtpRndm'");
}
}
if (!fNtpRndm) fRandom =
new TRandom3(0);
}
{
if (fNtpRndm) {
Long64_t ent = entry % fNtpRndm->GetEntries();
fNtpRndm->GetEntry(ent);
random = ar[0];
} else if (fRandom) {
fRandom->Rannor(px,py);
random = fRandom->Rndm();
} else {
Abort("no way to get random numbers! Stop processing", kAbortProcess);
}
fNtp->Fill(px,py,pz,random,i);
if (!fNtp2)
return kTRUE;
fNtp2->Fill(px,py,vz);
}
void ProofNtuple::SlaveTerminate()
{
if (fFile) {
if (!fNtp) {
Error(
"SlaveTerminate",
"'ntuple' is undefined!");
return;
}
if (fNtp->GetEntries() > 0) {
fFile->cd();
fProofFile->Print();
fOutput->Add(fProofFile);
} else {
}
fNtp->SetDirectory(0);
if (fNtp2) fNtp2->SetDirectory(0);
if (cleanup) {
TUrl uf(*(fFile->GetEndpointUrl()));
}
}
}
void ProofNtuple::Terminate()
{
if (!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");
}