Selector to process trees containing Event structures.
#define ProofEventProc_cxx
{
Info(
"Begin",
"starting a simple exercise with process option: %s", option.
Data());
}
void ProofEventProc::SlaveBegin(
TTree * )
{
if (fInput) {
if ((nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofEventProc_Read")))) {
}
}
if (!nm) {
if (option ==
"readall") fFullRead =
kTRUE;
}
Info(
"SlaveBegin",
"'%s' reading", (fFullRead ?
"full" :
"optimized"));
fPtHist =
new TH1F(
"pt_dist",
"p_{T} Distribution",100,0,5);
fPtHist->SetDirectory(0);
fPtHist->GetXaxis()->SetTitle("p_{T}");
fPtHist->GetYaxis()->SetTitle("dN/p_{T}dp_{T}");
fOutput->Add(fPtHist);
fPzHist =
new TH1F(
"pz_dist",
"p_{Z} Distribution",100,0,5.);
fPzHist->SetDirectory(0);
fPzHist->GetXaxis()->SetTitle("p_{Z}");
fPzHist->GetYaxis()->SetTitle("dN/dp_{Z}");
fOutput->Add(fPzHist);
fPxPyHist =
new TH2F(
"px_py",
"p_{X} vs p_{Y} Distribution",100,-5.,5.,100,-5.,5.);
fPxPyHist->SetDirectory(0);
fPxPyHist->GetXaxis()->SetTitle("p_{X}");
fPxPyHist->GetYaxis()->SetTitle("p_{Y}");
fOutput->Add(fPxPyHist);
if (fInput)
pi =
dynamic_cast<TParameter<Int_t> *
>(fInput->FindObject(
"ProofEventProc_TestAbort"));
if (pi) fTestAbort = pi->
GetVal();
if (fTestAbort < -1 || fTestAbort > 1) {
Info(
"SlaveBegin",
"unsupported value for the abort test: %d not in [-1,1] - ignore", fTestAbort);
fTestAbort = -1;
} else if (fTestAbort > -1) {
Info(
"SlaveBegin",
"running abort test: %d", fTestAbort);
}
if (fTestAbort == 0)
Abort("Test abortion during init", kAbortProcess);
}
{
if (fEntMin == -1 || entry < fEntMin) fEntMin = entry;
if (fEntMax == -1 || entry > fEntMax) fEntMax = entry;
if (fTestAbort == 1) {
if (rr > 0.999) {
Info(
"Process",
"%lld -> %f", entry, rr);
Abort("Testing file abortion", kAbortFile);
}
}
if (fFullRead) {
fChain->GetTree()->GetEntry(entry);
} else {
b_event_fNtrack->GetEntry(entry);
}
if (fNtrack > 0) {
if (!fFullRead) b_fTracks->GetEntry(entry);
if (fTracks) {
for (
Int_t j=0;j<fTracks->GetEntries();j++){
Track *curtrack =
dynamic_cast<Track*
>(fTracks->At(j));
if (curtrack) {
fPtHist->Fill(curtrack->GetPt(),1./curtrack->GetPt());
fPxPyHist->Fill(curtrack->GetPx(),curtrack->GetPy());
if (j == 0) fPzHist->Fill(curtrack->GetPz());
}
}
}
}
}
void ProofEventProc::SlaveTerminate()
{
if (fProcElem) fProcElem->Add(fEntMin, fEntMax);
if (!fProcElems) {
Warning(
"SlaveTerminate",
"no proc elements list found!");
return;
}
while ((o = nxpe())) { fOutput->Add(o); };
}
void ProofEventProc::Terminate()
{
CheckRanges();
if (
gROOT->IsBatch())
return;
TH1F *hi =
dynamic_cast<TH1F*
>(fOutput->FindObject(
"pz_dist"));
if (hi) {
}
else {
Warning(
"Terminate",
"no pz dist found"); }
TH1F *hf =
dynamic_cast<TH1F*
>(fOutput->FindObject(
"pt_dist"));
if (hf) {
}
else {
Warning(
"Terminate",
"no pt dist found"); }
TH2F *h2f =
dynamic_cast<TH2F*
>(fOutput->FindObject(
"px_py"));
if (h2f) {
} else {
Warning(
"Terminate",
"no px py found");
}
}
void ProofEventProc::CheckRanges()
{
if (!fOutput || (fOutput && fOutput->GetSize() <= 0)) return;
fOutput->Add(nout);
if (!fInput || (fInput && fInput->GetSize() <= 0)) {
return;
}
TNamed *ffst =
dynamic_cast<TNamed *
>(fInput->FindObject(
"Range_First_File"));
if (!ffst) {
return;
}
TNamed *flst =
dynamic_cast<TNamed *
>(fInput->FindObject(
"Range_Last_File"));
if (!flst) {
return;
}
if (!fnum) {
return;
}
nout->
SetTitle(
"No first entry information in first file name");
return;
}
sfst.
Remove(0, ifst +
sizeof(
"?fst=") - 1);
if (!sfst.IsDigit()) {
nout->
SetTitle(
"Badly formatted first entry information in first file name");
return;
}
ProcFileElements *pfef = dynamic_cast<ProcFileElements *>(fOutput->FindObject(fn));
if (!pfef) {
nout->
SetTitle(
"ProcFileElements for first file not found in the output list");
return;
}
if (pfef->GetFirst() != fst) {
return;
}
nout->
SetTitle(
"No last entry information in last file name");
return;
}
slst.
Remove(0, ilst +
sizeof(
"?lst=") - 1);
if (!slst.IsDigit()) {
nout->
SetTitle(
"Badly formatted last entry information in last file name");
return;
}
ProcFileElements *pfel = dynamic_cast<ProcFileElements *>(fOutput->FindObject(fn));
if (!pfel) {
nout->
SetTitle(
"ProcFileElements for last file not found in the output list");
return;
}
if (pfel->GetLast() != lst) {
return;
}
while ((o = nxo())) {
if (dynamic_cast<ProcFileElements *>(o)) nproc++;
}
if (fnum->
GetVal() != nproc) {
nout->
SetTitle(
"Number of processed files differs");
return;
}
}