Locked History Actions

Diff for "ANAROOT/Manual/analoop"

Differences between revisions 22 and 23
Deletions are marked like this. Additions are marked like this.
Line 66: Line 66:
=== 自前の計算ルーチンを組み込む ===
TAlEncSubを継承したクラスを自作してRegisterすればよい。
これの作り方は[[attachment:TAlEncUser.C]]と[[attachment:TAlEncUser.hh]]を参考にしてください。
あとはこれをロードして、
=== built-in your own TAlEncSub class ===
Create class inherits TAlEncSub and register by your self.
Pleas look [[attachment:TAlEncUser.C]] and [[attachment:TAlEncUser.hh]] for example.
Then by following commands,
Line 76: Line 76:
と普通に解析をはじめる。
自分で作ったTAlEncSubを継承したクラスをRegisterする過程は内部で(トリッキーに)実装しているので手動でやる必要はない。
analysis will start.
In above example, registering is done inside statical class construction (but this is tricky), so you don't need to do manually.
Line 79: Line 79:
=== anapaw: valに詰める -> anaroot: Add関数 ===
valに詰める代わりにAdd関数を使う。
このときanapawではデータが無いときに非物理量(-1000等)を詰めていたが、
anarootではAddしなければhistogramにはfillされない。
でも、非物理量を意識する必要はやっぱりあり、今NaNを使う方針が進行している。
TDCのover flowとかを詰めたいのなら詰めて構わないがその分パフォーマンスは落ちる。
=== anapaw: val[1][0] = auraw -> anaroot: Add(1, 0, auraw) ===
Use Add function instead of directly input to val.
In ANAROOT, you don't need to Add anything if there is nodata.
If you want to fill like over flow of TDC, it doesn't matter but performance will decrease.

Abstract of AnaLoop

AnaLoop(Exact class name is TArtAnaLoop) is a abstract class to control flow of analysis. Developer can make a class inherit TArtAnaLoop and required to implement 4 functions, Construct(), Calculate(), Destruct(), and ClassName(). Maybe it's easier to understand to look source code like TAlDALIExample.cc and .hh.

Construct()

This function is for construct like TArtCalibNEBULA, namely "new TArtCalibNEBULA". Constructing like TH1 is better to do in global book function (override it), but this is not essential and construct TH1 in Construct() is ok. You can find example of this in TArtAnaLoopUser.C.

Calculate()

This function will be called every event loop, so write only one step.

Destruct()

Just delete object which you create in Construct(). This part is important when you book twice or more at one root session.

ClassName()

This function only exists to show name of current AnaLoop class in status().

2 usage of AnaLoop

built-in to library

Create TArtAnaLoop derived class in $TARTSYS/source/AnaLoop/include and src. This suit to user whom you want to provide as black box.

create macro in your analysis directory and load dynamically

You can load same code as built-in one in ROOT session.

root[i] .L macros/TArtAnaLoopUser.C+

With "+" at end of line, ROOT will compile macro so you can use native C++ grammar (.x is execute command, so it's not proper). This suit to user who wants to edit frequently or familiar to ROOT and use TH1.

Special TArtAnaLoop derived class "TAlEncExample"

In TAlEncExample, register class inherits TAlEncSub and analysis each EncSub derived class in order of registration. This make us able to use <analys> and <stop> command in AnaFile. Registering manually, do as follows.

root[i] TAlEncExample* alencexample = new TAlEncExample;
root[i] alencexample->Register(new TAlEncSAMURAIExample);
root[i] alencexample->Register(new TAlEncDALIExample);
root[i] alencexample->Register(new TAlEncNEBULAExample);
root[i] book(alencexample);
root[i] push("ridf/sm_com/sdaq02/run0140.ridf");
root[i] start();

If you are using AnaFile, <analys> command will register automatically.

# hoge.ana
<analys> 0,15,12,

Command in ROOT session is normal,

root[i] book(new TAlEncExample, "hoge.ana");
root[i] push("ridf/sm_com/sdaq02/run0140.ridf");
root[i] start();

built-in your own TAlEncSub class

Create class inherits TAlEncSub and register by your self. Pleas look TAlEncUser.C and TAlEncUser.hh for example. Then by following commands,

root[i] .L macros/analoop/TAlEncUser.C+
root[i] book(new TAlEncExample, "ana/hoge.ana")
root[i] push("ridf/run0140.ridf")
root[i] start()

analysis will start. In above example, registering is done inside statical class construction (but this is tricky), so you don't need to do manually.

anapaw: val[1][0] = auraw -> anaroot: Add(1, 0, auraw)

Use Add function instead of directly input to val. In ANAROOT, you don't need to Add anything if there is nodata. If you want to fill like over flow of TDC, it doesn't matter but performance will decrease.

EAnalyser and EWNum

EAnalyserとEWNumはAnaFileでIDで物理量を指定するための列挙体。

src/source/AnaLoop/include/EAnalyser.hh
src/source/AnaLoop/include/EWNum.hh

に書く。 わかりやすいように定義の後ろに数字を書いているが、 現在はroot上で

root[i] lv();

と打てば見れるので書かなくてもいい。 ただし、C++の文法に完全に対応した処理をしているわけではないのである程度EAnalyser.hhとEWNum.hhの書き方は限られる。