1-hello |
2-mod |
3-pack |
4-pythia |
5-ATLFAST |
6-aodread |
7-sim |
8-dig |
9-rec |
10-aod |
復習
-------------------------------------------------------
> fs lq
> source /afs/cern.ch/sw/contrib/CMT/v1r20p20070720/mgr/setup.sh
cmthome> cmt config
cmthome> source setup.sh -tag=13.0.30
13.0.30> cmt co -r UserAnalysis-00-10-12 PhysicsAnalysis/AnalysisCommon/UserAnalysis
...> cd cmt
cmt> source setup.sh
cmt> gmake
run> get_files AthExHelloWorld_jobOptions.py
run> athena.py AthExHelloWorld_jobOptions.py
run> vi myjob
run> bsub -q 1nh myjob
run> bjobs
-----------------------------------------------------------
13.0.30> cmt co -r AthExHelloWorld-01-00-03 Control/AthenaExamples/AthExHelloWorld
> cd Control/AthenaExamples/AthExHelloWorld/src/HelloAlg.cxx の内容変更
> cd ../cmt
> cmt config
> source setup.sh
> gmake
~/testarea/13.0.30/PhysicsAnalysis/AnalysisCommon/UserAnalysis/run の方へ引き返してから、
>athena.py AthExHelloWorld_jobOptions.py を実行したら
cmt> gmake clean 動いたけど何しているの??
cmt> cmt rm -fR ../i686-slc4-gcc34* と入れてクリーンアップ
13.0.30% rm -fr InstallAreaとしてInstallAreaを全部消す
-------------------------------------------------------------
(5) Creating a New Package (2008.5.10卒業,5.17復習)
> cd testarea/13.0.30
> cmt create MyNewPackage MyNewPackage-00-00-01
これでDirectroy MyNewPackageができ cmt/,src/ができる。cmt/内は
-rw-r--r-- 1 kondo zp 424 May 17 10:02 cleanup.sh
-rw-r--r-- 1 kondo zp 82 May 17 10:02 Makefile
-rw-r--r-- 1 kondo zp 23 May 17 10:02 requirements
-rw-r--r-- 1 kondo zp 537 May 17 10:02 setup.sh
-rw-r--r-- 1 kondo zp 23 May 17 10:02 version.cmt
> cd MyNewPackage/cmt
MyNewPackage/cmt/requirementsを以下のようにする:
#################################################
package MyNewPackage
author ATLAS Workbook
use AtlasPolicy AtlasPolicy-01-*
use GaudiInterface GaudiInterface-01-* External
library MyNewPackage *.cxx -s=components *.cxx
apply_pattern component_library
apply_pattern declare_joboptions files="MyJobOptions.py"
#################################################
> cd ../src
Create a file MyAlg.cxx:
#include "MyNewPackage/MyAlg.h"
#include "GaudiKernel/MsgStream.h"
/////////////////////////////////////////////////////////////////////////////
MyAlg::MyAlg(const std::string& name, ISvcLocator* pSvcLocator) :
Algorithm(name, pSvcLocator)
{
// Properties go here
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
StatusCode MyAlg::initialize(){
MsgStream log(msgSvc(), name());
log << MSG::INFO << "initialize()" << endreq;
return StatusCode::SUCCESS;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
StatusCode MyAlg::execute() {
MsgStream log(msgSvc(), name());
log << MSG::INFO << "execute()" << endreq;
log << MSG::INFO << "Your new package and algorithm are successfully installed" << endreq;
return StatusCode::SUCCESS;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
StatusCode MyAlg::finalize() {
MsgStream log(msgSvc(), name());
log << MSG::INFO << "finalize()" << endreq;
return StatusCode::SUCCESS;
}
You also need to create two files
that are used to create entry points into a dynamically
loaded library, so you can say at runtime
"load this alg" and it will be found in the correct
library and be loaded into memory.
> mkdir components
> cd components
Create a file called MyNewPackage_entries.cxx containing this:
#include "MyNewPackage/MyAlg.h"
#include "GaudiKernel/DeclareFactoryEntries.h"
DECLARE_ALGORITHM_FACTORY( MyAlg )
DECLARE_FACTORY_ENTRIES(MyNewPackage) {
DECLARE_ALGORITHM( MyAlg );
}
MyNewPackage_load.cxxも作れ
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES(MyNewPackage)
Next you should create the header files:
> cd ../..
> mkdir MyNewPackage
> cd MyNewPackage
Create a file MyAlg.h:
#include "GaudiKernel/Algorithm.h"
/////////////////////////////////////////////////////////////////////////////
class MyAlg:public Algorithm {
public:
MyAlg (const std::string& name, ISvcLocator* pSvcLocator);
StatusCode initialize();
StatusCode execute();
StatusCode finalize();
};
Finally, you should create a JobOptions file.
> cd ..
> mkdir share
> cd share
Create a file MyJobOptions.py:
#--------------------------------------------------------------
# Private Application Configuration options
#--------------------------------------------------------------
# Full job is a list of algorithms
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()
# Add top algorithms to be run
from MyNewPackage.MyNewPackageConf import MyAlg
job += MyAlg( "MyNewPackage" ) # 1 alg, named "HelloWorld"
#--------------------------------------------------------------
# Set output level threshold (DEBUG, INFO, WARNING, ERROR, FATAL)
#--------------------------------------------------------------
job.MyNewPackage.OutputLevel = INFO
#--------------------------------------------------------------
# Event related parameters
#--------------------------------------------------------------
# Number of events to be processed (default is 10)
theApp.EvtMax = 1
#==============================================================
Note that you do not need to create MyNewPackageConf.py yourself.
This is generated as part of the build process in the genconf
directory of MyNewPackage and then installed in
InstallArea/python/MyNewPackage.
Building the New Package
Now build your package: > cd ../cmt
> cmt config
> source setup.sh
> gmake
ここでgenConf/ i686-slc4-gcc34-opt/ が自動的にできており
genConf/の中には __init__.py MyNewPackage2_confDb.py MyNewPackage2Conf.py がある。
If all is well you should be able to go to your run directory:
> cd ~/testarea/13.0.30
> cd PhysicsAnalysis/AnalysisCommon/UserAnalysis/run
> cp ../../../../MyNewPackage/share/MyJobOptions.py .
> athena.py MyJobOptions.py
If all is well you should see lines like this in the output:
MyAlg INFO initialize()
MyAlg INFO execute()
MyAlg INFO Your new package and algorithm are successfully installed
MyAlg INFO finalize()
MyAlg の代わりに
MyNewPackage INFO initialize()
MyNewPackage INFO execute()
MyNewPackage INFO Your new package and algorithm are successfully installed
MyNewPackage INFO finalize()
だった!
教訓:タイプして入れたのは必ず間違う!! ,と.が間違った。
最終的には~/testarea/13.0.30/MyNewPackageの中身は以下のようになった:
--------------------------------------------------------------------------------------
2 kondo zp 2048 May 10 18:31 cmt/
1 kondo zp 22 May 10 16:55 version.cmt
1 kondo zp 533 May 10 16:55 setup.sh
1 kondo zp 82 May 10 16:55 Makefile
1 kondo zp 422 May 10 16:55 cleanup.sh
1 kondo zp 361 May 10 17:03 requirements
1 kondo zp 58795 May 10 18:05 i686-slc4-gcc34-opt.make
1 kondo zp 58795 May 10 18:05 i686-slc4-gcc34-opt_MyNewPackage_check_install_joboptions.make
3 kondo zp 2048 May 10 17:50 src/
1 kondo zp 1047 May 10 17:07 MyAlg.cxx
2 kondo zp 2048 May 10 18:04 components/
1 kondo zp 185 May 10 17:16 MyNewPackage_entries.cxx
1 kondo zp 79 May 10 18:04 MyNewPackage_load.cxx
2 kondo zp 2048 May 10 17:56 MyNewPackage/
1 kondo zp 305 May 10 17:22 MyAlg.h
2 kondo zp 2048 May 10 17:58 share/
1 kondo zp 935 May 10 17:25 MyJobOptions.py
2 kondo zp 2048 May 10 18:05 genConf/
1 kondo zp 40 May 10 18:05 __init__.py
1 kondo zp 436 May 10 18:05 MyNewPackage_confDb.py
1 kondo zp 898 May 10 18:05 MyNewPackageConf.py
4 kondo zp 2048 May 10 18:06 i686-slc4-gcc34-opt/
1 kondo zp 5477 May 10 18:05 install_includes.make
1 kondo zp 4637 May 10 18:06 install_joboptions.make
1 kondo zp 73652 May 10 18:05 libMyNewPackage.a
1 kondo zp 41272 May 10 18:05 libMyNewPackage.so*などたくさん
--------------------------------------------------------------------------------------