Hi Ben, Are you sure that you do not have a gROOT->Reset() statement left in your code ? Could you try with t4->Process("myselect.C+") instead of t4->Process("myselect.C") Rene Brun On Tue, 21 May 2002, Ben Morgan wrote: > Hi ROOTers, > I'm currently writing a named script (ROOT v3.02/07 on Linux > PC running RH7.1) to perform cuts a series > of files, each one containing a tree holding the data objects. I've used > MakeSelector to build the skeleton selector code for this tree. Due to the > nature of the data, I want to analyse each file separately and then > append the TEventList generated by the MakeSelector code to this file. My > script loops over each file in turn (I've included the script code below), > but each time the line "t4->Process(...);" is executed, I get the error > message: > > Function Analyse() busy. loaded after > "/home/morgan/Analysis/drift1/protodrift/TDriftEvent/./Analyse.C" > Error: G__unloadfile() Can not unload > "/home/morgan/Analysis/drift1/protodrift/TDriftEvent/./Analyse.C", file > busy FILE:Analyse.C LINE:21 > *** Interpreter error recovered *** > > This doesn't seem to affect the execution (first time), but if I try to > execute it again, I get the error message: > > Function Analyse() busy. loaded after "/cern/root/lib/libProof.so" > Error: G__unloadfile() Can not unload "/cern/root/lib/libProof.so", file > busy FILE:Analyse.C LINE:32 > *** Interpreter error recovered *** > > Also, on second execution, the script falls over with a seg fault that > seems to be due to how I write the list to the file (I use Write with the > fOverwrite option because I'm tuning cuts and only want one list in > there), I've included the > relevant code fragments from the selector code below as well. I'm making > some really simple mistake, but any help would be very gratefully > received! Thanks, > > Ben Morgan. > > CODE FOR ANALYSE > ------------------------------------------------------------------------------ > #include <iostream.h> > > int Analyse() > { > char filedirectory[100]; > char filename[100]; > int lowrun, uprun; > > cout<<"Enter directory containing files to be analysed: "<<endl; > cin>>filedirectory; > > cout<<"Enter run number bounds to be analysed: "; > cin>>lowrun>>uprun; > cout<<endl; > > for(int i=lowrun; i<(uprun+1); i++) > { > if(gROOT->FindObject(filename)) > delete gROOT->FindObject(filename); > > sprintf(filename,"%s/Trun0%d.root",filedirectory,i); > > cout<<"Start of loop for file "<<filename<<endl; > TFile *f = new TFile(filename,"update"); > > cout<<"Address of Tfile Object is "<<f<<endl; > TTree *t4 = (TTree*)f.Get("DriftEventData"); > > t4->Process("EventSelector.C","fillList"); > > cout<<"End of loop "<<i<<endl<<endl; > } > > if(gROOT->FindObject(filename)) > delete gROOT->FindObject(filename); > > return 0; > } > ------------------------------------------------------------------------------- > > MAKESELECTOR FUNCTIONS > ------------------------------------------------------------------------------- > TEventList *clist = 0; > Bool_t useList, fillList; > > void EventSelector::Begin(TTree *tree) > { > // Function called before starting the event loop. > // Initialize the tree branches. > > Init(tree); > > TString option = GetOption(); > fillList=kFALSE; > useList=kFALSE; > fChain->SetEventList(0); > delete gDirectory->GetList()->FindObject("clist"); > > if (option.Contains("fillList")) { > fillList = kTRUE; > clist = new TEventList("clist","selection from Cut",5000); > } > > if (option.Contains("useList")) { > useList = kTRUE; > TFile *f = fChain->GetCurrentFile(); > elist = (TEventList*)f.Get("clist"); > if (elist) elist->SetDirectory(0); > fChain->SetEventList(clist); > } > > > cout<<"In Selector, current file is: "<<fChain->GetCurrentFile()<<endl; > > } > > > void EventSelector::Terminate() > { > // Function called at the end of the event loop. > > if(fillList) > { > cout<<"Writing (Rewriting) List to File"<<endl; > clist->Write("clist",TObject::kOverwrite); > } > > cout<<"Termintate Selector Loop"<<endl; > > } > > > -- > ------------------------------------------------------------------------------- > Mr. Ben Morgan > Postgraduate Student > University of Sheffield > Department of Physics & Astronomy > Hicks Building > Hounsfield Road > Sheffield S3 7RH > ------------------------------------------------------------------------------- >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:53 MET