10 #define ProofEventProc_cxx
26 void ProofEventProc::Begin(TTree *)
32 TString option = GetOption();
33 Info(
"Begin",
"starting a simple exercise with process option: %s", option.Data());
37 void ProofEventProc::SlaveBegin(TTree * )
43 TString option = GetOption();
49 if ((nm = dynamic_cast<TNamed *>(fInput->FindObject(
"ProofEventProc_Read")))) {
50 if (!strcmp(nm->GetTitle(),
"readall")) fFullRead = kTRUE;
55 if (option ==
"readall") fFullRead = kTRUE;
57 Info(
"SlaveBegin",
"'%s' reading", (fFullRead ?
"full" :
"optimized"));
59 fPtHist =
new TH1F(
"pt_dist",
"p_{T} Distribution",100,0,5);
60 fPtHist->SetDirectory(0);
61 fPtHist->GetXaxis()->SetTitle(
"p_{T}");
62 fPtHist->GetYaxis()->SetTitle(
"dN/p_{T}dp_{T}");
64 fOutput->Add(fPtHist);
66 fPzHist =
new TH1F(
"pz_dist",
"p_{Z} Distribution",100,0,5.);
67 fPzHist->SetDirectory(0);
68 fPzHist->GetXaxis()->SetTitle(
"p_{Z}");
69 fPzHist->GetYaxis()->SetTitle(
"dN/dp_{Z}");
71 fOutput->Add(fPzHist);
73 fPxPyHist =
new TH2F(
"px_py",
"p_{X} vs p_{Y} Distribution",100,-5.,5.,100,-5.,5.);
74 fPxPyHist->SetDirectory(0);
75 fPxPyHist->GetXaxis()->SetTitle(
"p_{X}");
76 fPxPyHist->GetYaxis()->SetTitle(
"p_{Y}");
78 fOutput->Add(fPxPyHist);
81 TParameter<Int_t> *pi = 0;
83 pi =
dynamic_cast<TParameter<Int_t> *
>(fInput->FindObject(
"ProofEventProc_TestAbort"));
84 if (pi) fTestAbort = pi->GetVal();
85 if (fTestAbort < -1 || fTestAbort > 1) {
86 Info(
"SlaveBegin",
"unsupported value for the abort test: %d not in [-1,1] - ignore", fTestAbort);
88 }
else if (fTestAbort > -1) {
89 Info(
"SlaveBegin",
"running abort test: %d", fTestAbort);
93 Abort(
"Test abortion during init", kAbortProcess);
97 Bool_t ProofEventProc::Process(Long64_t entry)
117 if (fEntMin == -1 || entry < fEntMin) fEntMin = entry;
118 if (fEntMax == -1 || entry > fEntMax) fEntMax = entry;
120 if (fTestAbort == 1) {
121 Double_t rr = gRandom->Rndm();
123 Info(
"Process",
"%lld -> %f", entry, rr);
124 Abort(
"Testing file abortion", kAbortFile);
130 fChain->GetTree()->GetEntry(entry);
132 b_event_fNtrack->GetEntry(entry);
136 if (!fFullRead) b_fTracks->GetEntry(entry);
138 for (Int_t j=0;j<fTracks->GetEntries();j++){
139 Track *curtrack =
dynamic_cast<Track*
>(fTracks->At(j));
141 fPtHist->Fill(curtrack->GetPt(),1./curtrack->GetPt());
142 fPxPyHist->Fill(curtrack->GetPx(),curtrack->GetPy());
143 if (j == 0) fPzHist->Fill(curtrack->GetPz());
154 void ProofEventProc::SlaveTerminate()
161 if (fProcElem) fProcElem->Add(fEntMin, fEntMax);
164 Warning(
"SlaveTerminate",
"no proc elements list found!");
169 TIter nxpe(fProcElems);
171 while ((o = nxpe())) { fOutput->Add(o); };
175 void ProofEventProc::Terminate()
184 if (gROOT->IsBatch())
return;
186 TCanvas* canvas =
new TCanvas(
"event",
"event",800,10,700,780);
188 TPad *pad1 = (TPad *) canvas->GetPad(1);
189 TPad *pad2 = (TPad *) canvas->GetPad(2);
190 TPad *pad3 = (TPad *) canvas->GetPad(3);
191 TPad *pad4 = (TPad *) canvas->GetPad(4);
196 TH1F *hi =
dynamic_cast<TH1F*
>(fOutput->FindObject(
"pz_dist"));
198 hi->SetFillColor(30);
202 }
else { Warning(
"Terminate",
"no pz dist found"); }
207 TH1F *hf =
dynamic_cast<TH1F*
>(fOutput->FindObject(
"pt_dist"));
209 hf->SetFillColor(30);
213 }
else { Warning(
"Terminate",
"no pt dist found"); }
216 TH2F *h2f =
dynamic_cast<TH2F*
>(fOutput->FindObject(
"px_py"));
220 h2f->DrawCopy(
"SURF1 ");
223 h2f->DrawCopy(
"CONT2COL");
225 Warning(
"Terminate",
"no px py found");
234 void ProofEventProc::CheckRanges()
240 if (!fOutput || (fOutput && fOutput->GetSize() <= 0))
return;
243 TNamed *nout =
new TNamed(
"Range_Check",
"OK");
247 if (!fInput || (fInput && fInput->GetSize() <= 0)) {
248 nout->SetTitle(
"No input list");
251 TNamed *ffst =
dynamic_cast<TNamed *
>(fInput->FindObject(
"Range_First_File"));
253 nout->SetTitle(
"No first file");
256 TNamed *flst =
dynamic_cast<TNamed *
>(fInput->FindObject(
"Range_Last_File"));
258 nout->SetTitle(
"No last file");
261 TParameter<Int_t> *fnum =
262 dynamic_cast<TParameter<Int_t> *
>(fInput->FindObject(
"Range_Num_Files"));
264 nout->SetTitle(
"No number of files");
269 TString fn(ffst->GetTitle()), sfst(ffst->GetTitle());
270 Ssiz_t ifst = fn.Index(
"?fst=");
272 nout->SetTitle(
"No first entry information in first file name");
276 sfst.Remove(0, ifst +
sizeof(
"?fst=") - 1);
277 if (!sfst.IsDigit()) {
278 nout->SetTitle(
"Badly formatted first entry information in first file name");
281 Long64_t fst = (Long64_t) sfst.Atoi();
282 ProcFileElements *pfef =
dynamic_cast<ProcFileElements *
>(fOutput->FindObject(fn));
284 nout->SetTitle(
"ProcFileElements for first file not found in the output list");
287 if (pfef->GetFirst() != fst) {
288 TString t = TString::Format(
"First entry differs {found: %lld, expected: %lld}", pfef->GetFirst(), fst);
289 nout->SetTitle(t.Data());
294 fn = flst->GetTitle();
295 TString slst(flst->GetTitle());
296 Ssiz_t ilst = fn.Index(
"?lst=");
298 nout->SetTitle(
"No last entry information in last file name");
302 slst.Remove(0, ilst +
sizeof(
"?lst=") - 1);
303 if (!slst.IsDigit()) {
304 nout->SetTitle(
"Badly formatted last entry information in last file name");
307 Long64_t lst = (Long64_t) slst.Atoi();
308 ProcFileElements *pfel =
dynamic_cast<ProcFileElements *
>(fOutput->FindObject(fn));
310 nout->SetTitle(
"ProcFileElements for last file not found in the output list");
313 if (pfel->GetLast() != lst) {
314 nout->SetTitle(
"Last entry differs");
322 while ((o = nxo())) {
323 if (dynamic_cast<ProcFileElements *>(o)) nproc++;
325 if (fnum->GetVal() != nproc) {
326 nout->SetTitle(
"Number of processed files differs");