|
|
|
|
|
HowTo: make ROOT and JobControl play nice |
(note: configuring offline jobs via .jcm language is depreciated)
On the one hand Mark Messier has developed a nice job control system for assembling a job from component pieces and configuring and running those paths via jcm scripts. The problem is that it is very batch-oriented: the components had to be precompiled JobCModules and there was no way to "talk" to root except by writing C++ and compiling it into a module or something a module would call from one of the shared libaries.
#======================================================================= # # A simple .jcm demonstrating the JobCRootModule facilities # # usage: demojob -bqx test_root.jcm # # rhatcher@fnal.gov #======================================================================= echo help Root # reset ROOT /Root/Reset # set the ROOT "style" to "Default" /Root/SetStyle Default # load some dynamic libraries /Root/LoadLibrary libRecoBase.so /Root/LoadClass MSTClusterListModule libBubbleSpeak.so # enable TObject statistics accumulation (poor mans leak checking) /Root/ObjectStat/Set 1 # run a "unnamed" macro /Root/RunMacro root_unnamed.C # run a macro that has a function with the same name as the file # and takes a single int argument /Root/RunMacro root_named.C(999) # load a macro that defines, amongst others, the functions # FillIntArray(Int_t* array, Int_t n) # DumpIntArray(Int_t* array, Int_t n) # this pseudo compiles it making it available for simple calling /Root/LoadMacro FileContains_DumpIntArray.C # compile, using the system compiler a file, producing and linking # in the resulting dynamic library /Root/CompileMacro good_code.cxx # process some arbitrary lines just like typing at the ROOT prompt /Root/ProcessLine Int_t n = 100 /Root/ProcessLine cout << n << endl /Root/ProcessLine Int_t *myarray = new Int_t[n] /Root/ProcessLine FillIntArray(myarray,n) /Root/ProcessLine DumpIntArray(myarray,n) /Root/ProcessLine #include "TString.h" /Root/ProcessLine TCanvas *cv1 = new TCanvas("cv1","cv1",600,600); # show the the TObject statistics, turn off accounting /Root/ObjectStat/Print /Root/ObjectStat/Set 1
Let's take the example of having a C++ macro script one wanted run during the BeginJob phase, call this noargs.C. And there is another to be run at a particular point while running a path: rummage_mom.C. If one defines a job path in rootcmd.jcm one can run the path using demojob -bqx rootcmd.jcm.
#======================================================================= # # A simple .jcm demonstrating the JobCRootCommandModule facilities # # usage: demojob -bqx rootcmd.jcm # # rhatcher@fnal.gov #======================================================================= # load the macros so they aren't re-pseudo-compiled each time /Root/LoadMacro noargs.C /Root/LoadMacro rummage_mom.C # create a path /Path/Create RootCmdTest \ Input::Get \ RerootToRawDataModule::Get \ RootCommand::Ana # add a line that is processed at BeginJob -- no mom available so # macro better not rely on there being one /RootCmdTest/RootCommand/AddLine/BeginJob noargs() # add a line that is proccessed each time RootCommand::Ana is # add a line that is proccessed each time RootCommand::Ana is # encountered in the RootCmdTest path /RootCmdTest/RootCommand/AddLine/Ana rummage_mom(mom,"Ana") /RootCmdTest/Input/Add root_files/gm_far_cosmic_2_hapr01.root /RootCmdTest/Run Nin 5
RootCmdTest(0 in 0 out 0 filt.) 1) Input::Get in=0 pass=0 fail=0 t= 0.00 s 2) RerootToRawDataModule::Get in=0 pass=0 fail=0 t= 0.00 s 3) RootCommand::Ana in=0 pass=0 fail=0 t= 0.00 s | nevts = 8327 ngeos = 1 MINFast::GetEvent: New REROOT_Event record 0 comes from REROOT_Geom record 0 ******** this is a macro with no args ::AddToCrate cutting all raw values < 0.299900 rummage_mom got mom = 0x93d4580 Ana List of Fragments in MomNavigator: [0] RawRecord: "" rummage_mom got mom = 0x93d4580 Ana List of Fragments in MomNavigator: [0] RawRecord: "" Processed 2 records: RootCmdTest(2 in 2 out 0 filt.) 1) Input::Get in=2 pass=2 fail=0 t= 0.08 s 2) RerootToRawDataModule::Get in=2 pass=2 fail=0 t= 0.14 s 3) RootCommand::Ana in=2 pass=2 fail=0 t= 0.36 s
void noargs() { cout << " ******** this is a macro with no args" << endl; }
void rummage_mom(const MomNavigator* mom, char* byWhom) { cout << "rummage_mom got mom = " << mom << " " << byWhom << endl; if (!mom) { cout << "rummage_mom had a null mom ... attempt JobCROOT::GetMom()"; // Attach the current mom ... may fail with an assert() JobCROOT& jc = JobCROOT::Instance(); MomNavigator *mom = jc.GetMom(); } // yes, this duplicates the functionality of DemoEventDump::DumpFragments // but it is meant only to be *instructive*, presumably one wants // to do more with what is in "mom" than simply dump it TIter fitr = mom->FragmentIter(); cout << "List of Fragments in MomNavigator:" << endl; TObject* tobj; int i = 0; while (tobj = (fitr()) ) { cout << " [" << i << "] " << tobj->ClassName() << ":" << tobj->GetName() << " \"" << tobj->GetTitle() << "\"" << endl; } }
| Security, Privacy, Legal |
|