10 #define ProofSimpleFile_cxx 29 ProofSimpleFile::ProofSimpleFile()
43 ProofSimpleFile::~ProofSimpleFile()
47 if (fRandom)
delete fRandom;
51 Int_t ProofSimpleFile::CreateHistoArrays()
56 Error(
"CreateHistoArrays",
"fNhist must be positive!");
60 fHistTop =
new TH1F*[fNhist];
61 fHistDir =
new TH1F*[fNhist];
77 if (fInput->FindObject(
"ProofSimpleFile_NHist")) {
81 }
else if ((iopt = option.
Index(
"nhist=")) !=
kNPOS) {
83 Ssiz_t from = iopt + strlen(
"nhist=");
89 void ProofSimpleFile::SlaveBegin(
TTree * )
99 if (fInput->FindObject(
"ProofSimpleFile_NHist")) {
103 }
else if ((iopt = option.
Index(
"nhist=")) !=
kNPOS) {
105 Ssiz_t from = iopt + strlen(
"nhist=");
112 if (out) fProofFile->SetOutputFileName(out->
GetTitle());
114 fFile = fProofFile->OpenFile(
"RECREATE");
115 if (fFile && fFile->IsZombie())
SafeDelete(fFile);
121 " instance is invalid!", fProofFile->GetName());
122 Abort(amsg, kAbortProcess);
127 if (CreateHistoArrays() != 0) {
128 Abort(
"ProofSimpleFile::SlaveBegin: could not create histograms", kAbortProcess);
133 if (!(fFileDir = fFile->mkdir(
"blue"))) {
134 Abort(
"ProofSimpleFile::SlaveBegin: could not create directory 'blue' in file!",
140 for (
Int_t i=0; i < fNhist; i++) {
141 fHistTop[i] =
new TH1F(
Form(
"ht%d",i),
Form(
"ht%d",i), 100, -3., 3.);
142 fHistTop[i]->SetFillColor(
kRed);
143 fHistTop[i]->SetDirectory(fFile);
144 fHistDir[i] =
new TH1F(
Form(
"hd%d",i),
Form(
"hd%d",i), 100, -3., 3.);
145 fHistDir[i]->SetFillColor(
kBlue);
146 fHistDir[i]->SetDirectory(fFileDir);
174 for (
Int_t i=0; i < fNhist; i++) {
175 if (fRandom && fHistTop[i] && fHistDir[i]) {
176 fHistTop[i]->Fill(fRandom->Gaus(0.,1.));
177 fHistDir[i]->Fill(fRandom->Gaus(0.,1.));
185 void ProofSimpleFile::SlaveTerminate()
196 for (
Int_t i=0; i < fNhist; i++) {
197 if (fHistTop[i] && fHistTop[i]->GetEntries() > 0) {
198 fHistTop[i]->Write();
199 fHistTop[i]->SetDirectory(0);
205 for (
Int_t i=0; i < fNhist; i++) {
206 if (fHistDir[i] && fHistDir[i]->GetEntries() > 0) {
207 fHistDir[i]->Write();
208 fHistDir[i]->SetDirectory(0);
216 Info(
"SlaveTerminate",
"nothing to save: just cleanup everything ...");
217 TUrl uf(*(fFile->GetEndpointUrl()));
222 Info(
"SlaveTerminate",
"objects saved into '%s%s': sending related TProofOutputFile ...",
223 fProofFile->GetFileName(), fProofFile->GetOptionsAnchor());
225 fOutput->Add(fProofFile);
232 void ProofSimpleFile::Terminate()
240 dynamic_cast<TProofOutputFile*>(fOutput->FindObject(
"SimpleFile.root")))) {
242 TString outputFile(fProofFile->GetOutputFileName());
243 TString outputName(fProofFile->GetName());
244 outputName +=
".root";
245 Printf(
"outputFile: %s", outputFile.Data());
249 Error(
"Terminate",
"could not open file: %s", outputFile.Data());
254 Error(
"Terminate",
"TProofOutputFile not found");
259 if (CreateHistoArrays() != 0) {
260 Error(
"Terminate",
"could not create histograms");
271 void ProofSimpleFile::PlotHistos(
Int_t opt)
277 TCanvas *
c1 =
new TCanvas(
"c1",
"ProofSimpleFile top dir canvas",200,10,700,700);
279 nside = (nside*nside < fNhist) ? nside+1 : nside;
280 c1->
Divide(nside,nside,0,0);
282 for (
Int_t i=0; i < fNhist; i++) {
292 }
else if (opt == 1) {
293 TCanvas *
c2 =
new TCanvas(
"c2",
"ProofSimpleFile 'blue' sub-dir canvas",400,60,700,700);
295 nside = (nside*nside < fNhist) ? nside+1 : nside;
296 c2->
Divide(nside,nside,0,0);
298 if ((fFileDir = (
TDirectory *) fFile->Get(
"blue"))) {
299 for (
Int_t i=0; i < fNhist; i++) {
306 Error(
"PlotHistos",
"directory 'blue' not found in output file");
313 Error(
"PlotHistos",
"unknown option: %d", opt);
Random number generator class based on M.
virtual void Draw(Option_t *option="")=0
Default Draw method for all objects.
This class represents a WWW compatible URL.
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
1-D histogram with a float per channel (see TH1 documentation)}
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
The TNamed class is the base class for all named ROOT classes.
void Info(const char *location, const char *msgfmt,...)
virtual void Close(Option_t *option="")
Delete all objects from memory and directory structure itself.
void Error(const char *location, const char *msgfmt,...)
Named parameter, streamable and storable.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
R__EXTERN TSystem * gSystem
char * Form(const char *fmt,...)
Class to steer the merging of files produced on the workers.
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Describe directory structure in memory.
static constexpr double s
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Selector to fill a set of histograms and merging via file.
Int_t Atoi() const
Return integer value of string.
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
A TTree object has a header with a name and a title.
const AParamType & GetVal() const
Double_t Sqrt(Double_t x)
virtual void Update()
Update canvas pad buffers.
virtual const char * GetTitle() const
Returns title of object.