55 if (act ==
"GenerateTreesSameFile") {
57 }
else if (act.BeginsWith(
"GenerateTrees")) {
63 act.Remove(0, icol+1);
64 if (!act.IsNull()) fDir = act;
84 void ProofAux::SlaveBegin(
TTree * )
93 fAction = GetAction(fInput);
97 if (a) fNEvents = a->
GetVal();
100 fMainList =
new TList;
103 fFriendList =
new TList;
131 Error(
"Process",
"action not specified!");
138 if (fInput && (elemPair = dynamic_cast<TPair *>(fInput->FindObject(
"PROOF_CurrentElement")))) {
139 if ((fCurrent = dynamic_cast<TDSetElement *>(elemPair->
Value()))) {
140 Info(
"Process",
"entry %lld: file: '%s'", entry, fCurrent->
GetName());
142 Error(
"Process",
"entry %lld: no file specified!", entry);
151 if (GenerateTree(fCurrent->
GetName(), fNEvents, fnt) != 0) {
152 Error(
"Process",
"problems generating tree (%lld, %s, %lld)",
153 entry, fCurrent->
GetName(), fNEvents);
171 if (GenerateFriend(fnt, fnf) != 0) {
172 Error(
"Process",
"problems generating friend tree for %s (%s)",
176 }
else if (fAction == 1) {
179 if (GenerateTree(fCurrent->
GetName(), fNEvents, fnt) != 0) {
180 Error(
"Process",
"problems generating tree (%lld, %s, %lld)",
181 entry, fCurrent->
GetName(), fNEvents);
185 if (GenerateFriend(fnt) != 0) {
186 Error(
"Process",
"problems generating friend tree for %s (%s)",
190 }
else if (fAction == 2) {
193 if (GenerateTree(fCurrent->
GetName(), fNEvents, fnt) != 0) {
194 Error(
"Process",
"problems generating tree (%lld, %s, %lld)",
195 entry, fCurrent->
GetName(), fNEvents);
200 Warning(
"Process",
"do not know how to process action %d - do nothing", fAction);
208 void ProofAux::SlaveTerminate()
214 if (fMainList && fMainList->GetSize() > 0) fOutput->Add(fMainList);
215 if (fFriendList && fFriendList->GetSize() > 0) fOutput->Add(fFriendList);
219 void ProofAux::Terminate()
240 Error(
"GenerateTree",
"file name undefined!");
244 if (!strcmp(uu.GetProtocol(),
"file") && !fn.
BeginsWith(
"/")) {
248 Error(
"GenerateTree",
"data directory undefined!");
257 Error(
"GenerateTree",
"problems creating directory %s to store the file", dir.
Data());
267 Error(
"GenerateTree",
"problems opening file %s", fn.
Data());
274 if (!fDir.IsNull()) {
275 if (f->
mkdir(fDir.Data())) {
276 Info(
"GenerateTree",
"sub-directory '%s' successfully created", fDir.Data());
280 Error(
"GenerateTree",
"creating sub-directory '%s'", fDir.Data());
290 TTree *
T =
new TTree(
"Tmain",
"Main tree for tutorial friends");
293 T->
Branch(
"Run",&Run,
"Run/I");
295 T->
Branch(
"Event",&Event,
"Event/L");
301 for (
Long64_t i = 0; i < ent; i++) {
302 if (i > 0 && i%1000 == 0) Run++;
318 Info(
"GenerateTree",
"file '%s' successfully created", fn.
Data());
322 if (!strcmp(uu.GetProtocol(),
"file")) {
337 Int_t ProofAux::GenerateFriend(
const char *fnt,
const char *fnf)
351 Error(
"GenerateFriend",
"file name for the main tree undefined!");
356 Error(
"GenerateFriend",
"input file does not exist or cannot be read: %s", fin.Data());
362 const char *openMain =
"UPDATE";
366 if (!fout.IsNull()) {
373 Error(
"GenerateFriend",
"problems creating directory %s to store the file", dir.
Data());
385 Error(
"GenerateFriend",
"problems opening input file %s", fin.Data());
390 Error(
"GenerateFriend",
"problems getting tree 'Tmain' from file %s", fin.Data());
407 fo =
new TFile(fout,
"RECREATE");
409 Error(
"GenerateFriend",
"problems opening file %s", fout.Data());
421 TTree *Tfrnd =
new TTree(
"Tfrnd",
"Friend tree for tutorial 'friends'");
424 Tfrnd->
Branch(
"r",&r,
"r/F");
426 for (
Long64_t i = 0; i < ent; i++) {
446 Info(
"GenerateFriend",
"friend file '%s' successfully created", fout.Data());
450 if (!strcmp(uu.GetProtocol(),
"file")) {
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual const char * GetName() const
Returns name of object.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual TDirectory * mkdir(const char *name, const char *title="")
Create a sub-directory "a" or a hierarchy of sub-directories "a/b/c/...".
Collectable string class.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
virtual void Print(Option_t *option="") const
Print a summary of the tree contents.
This class represents a WWW compatible URL.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual Int_t Fill()
Fill all branches.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
TString & Insert(Ssiz_t pos, const char *s)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Manages an element of a TDSet.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
This is the base class for the ROOT Random number generators.
The TNamed class is the base class for all named ROOT classes.
virtual const char * Getenv(const char *env)
Get environment variable.
void Info(const char *location, const char *msgfmt,...)
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
void Error(const char *location, const char *msgfmt,...)
R__ALWAYS_INLINE Bool_t IsZombie() const
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
R__EXTERN TSystem * gSystem
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all leaves of entry and return total number of bytes read.
void SetName(const char *name)
void Warning(const char *location, const char *msgfmt,...)
Class used by TMap to store (key,value) pairs.
virtual void SetDirectory(TDirectory *dir)
Change the tree's directory.
virtual const char * HostName()
Return the system's host name.
Describe directory structure in memory.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Selector used for auxiliary actions in the PROOF tutorials.
virtual Long64_t GetEntries() const
you should not use this method at all Int_t Int_t z
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
virtual Bool_t cd(const char *path=0)
Change current directory to "this" directory.
R__EXTERN TProofServ * gProofServ
A TTree object has a header with a name and a title.
const AParamType & GetVal() const
Double_t Sqrt(Double_t x)
A TTree is a list of TBranches.
const char * GetDataDir() const
virtual Double_t Landau(Double_t mean=0, Double_t sigma=1)
Generate a random number following a Landau distribution with location parameter mu and scale paramet...
const char * GetOrdinal() const
virtual const char * GetTitle() const
Returns title of object.
virtual void Close(Option_t *option="")
Close a file.
const char * Data() const