CBM Simulation & Analysis Framework Analysis Tasks

25
12.05.2004 CBM Software week 1 CBM Simulation & Analysis CBM Simulation & Analysis Framework Framework Analysis Tasks Analysis Tasks M. Al-Turany, D. Bertini

description

CBM Simulation & Analysis Framework Analysis Tasks. M. Al-Turany, D. Bertini. CBM Analysis and Simulation Framework. Urqmd. G3. G4. FLUKA. Pluto. Magnet. ROOT. Ion Generator. Geometry Manager. Generators. Target. Virtual MC. Particle Generator. PIPE. ASCII. Cave. - PowerPoint PPT Presentation

Transcript of CBM Simulation & Analysis Framework Analysis Tasks

Page 1: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 1

CBM Simulation & Analysis FrameworkCBM Simulation & Analysis Framework

Analysis TasksAnalysis Tasks

M. Al-Turany, D. Bertini

Page 2: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 2

ROOT

Run Manager

Virtual MC

G3 G4 FLUKA

Pluto

Ion Generator

Particle Generator

ASCIIPIPE

Target

STS

TRD

Cave

TOF

Magnet

RICH

Generators

Mixed Generator

Urqmd

Magnetic

Field

Module

Detector

GeometryManager

IO Manager

Tasks ListDelta

Tracking

Field Map

CBM Analysis and Simulation FrameworkCBM Analysis and Simulation Framework

digitizers

Page 3: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 3

Reading Output filesReading Output files

• The Simulation output files are ROOT files, the data in the TTree can be accessed in plain ROOT (using TBrowser or Tree Viewer).

• If you write a macro to read the file you have to load the CBM libraries.

• if you want to visualize the geometry, you have to load the ROOT TGeo library.

i.e. gSystem->Load("libGeom") is needed to be able to browse the geometry

Page 4: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 4

Output FileOutput FileCBMMCApplication

Geometry

Folder Structure

Output Tree

Page 5: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 5

The CBM VMC Application The CBM VMC Application

• To get the Application from Macro :– Tfile f("test.root");– CBMMCApplication *fcbm=f.Get("CBM");

• To get the Application in compiled code:– CBMMCApplication *fcbm=CBMMCApplication::Instance();

Page 6: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 6

The CBM VMC ApplicationThe CBM VMC Application

• fcbm->GetDetector(const char *DetName); – Returns a pointer to the detector "DetName"

• fcbm-> CBMMagField* GetField()– Returns the magnetic field used for this simulation

• fcbm-> CBMGenerator* GetGenerator(); – Returns the event generator used for this simulation

Page 7: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 7

The Magnetic Field The Magnetic Field

• To get the Magnetic field:

CBMMagField * fMag = fcbm-> CBMMagField* GetField();

• Now to reconstruct the field in Memory:– if you a const Field was used in simulation, this will be done

automatically.– if a field map was used:

• CBMFieldMap *fMap = dynamic_cast< CBMFieldMap *> (fMag)

• fMap->Init() will reconstruct the field in moemory

• In both cases you can now use :– fcbm->GetFieldValue( const Double_t Point[3], Double_t *Bfield[3] )

This will get the field value Bfield[3] at Point[3]

Page 8: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 8

The Output TreeThe Output Tree

Detector BrachesStack

Page 9: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 9

Reading from the TreeReading from the Tree

• To access a branch from the Tree:– Get a pointer to the ROOT Manager:

CBMRootManager *fManager= CBMRootManager::Instance();

– Let the ROOT manager activate your branch:fManager->ActivateBranch(const char *BrName) ;

BrName : The branch name

e.g:

TClonesArray * STSpts=

(TClonesArray *) fManger->ActivateBranch("STSPoint");

Page 10: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 10

CBMTasksCBMTasks

• Tasks can be organized into a hierarchy and displayed in the browser.

• The CBMTask class is the base class from which the tasks are derived.

• To give task functionality, you need to subclass the CBMTask class and override:– Init(); //Initialization

– Exec(Option_t * option);

Page 11: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 11

Tasks MechanismTasks Mechanism

CBMTask *Task1=new CBMTask("Task1") CBMTask *Task2=new CBMTask("Task2")

CBMTask *Task3=new CBMTask("Task3")

CBMTask *Task4=new CBMTask("Task4")

CBMTask *Task5=new CBMTask("Task5")

CBMTask *Task6=new CBMTask("Task6")

Task1->Add(Task2)

Task1->Add(Task3)

Task2->Add(Task4)

Task2->Add(Task5)

Task3->Add(Task6)

Task1

Task2 Task3

Task4 Task6Task5

Page 12: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 12

TasksTasks

Page 13: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 13

CBMTaskCBMTask

class CBMTask : public TTask {

public:

/** Initialization of the task. */

virtual void Init();

/** Re-initialization of the task */

virtual void ReInit(); // *MENU*

/** Recursive initialization of all subtasks */

virtual void InitTasks(); // *MENU*

virtual void Finish();

/** Recursive for all subtasks */

virtual void FinishTasks(); // *MENU*

Page 14: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 14

Creating a TaskCreating a Task

class CBMITrack : public CBMTask {

public:

CBMDITrack(const char *name, const char *title="CBM Task");

virtual void Init(); //Initialization

virtual void Exec(Option_t * option); //called for each event

virtual void Finish(); //called for each event

virtual ~CBMITrack();

ClassDef(CBMITrack,1) //CBMITrack

}

Page 15: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 15

Analysis Task- Init exampleAnalysis Task- Init example

void CBMITrack::Init()

{

// Get a pointer to the ROOT Manager ( data store )

CBMRootManager *fManager =CBMRootManager::Instance();

// Get the relevant data for the Task

// activate in IO the corresponding TTree branch

fListSTSpts=(TClonesArray *)fManager->ActivateBranch("STSPoint");

//Create a new branch in the output file for the results

fHitCollection = new TClonesArray("CBMSTSDoubleHit");

fManager->Register("STSDoubleHit","STS", fHitCollection);

}

Page 16: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 16

Analysis Task- Exec exampleAnalysis Task- Exec example

void CBMITrack::Exec(Option_t * option)

{

CBMSTSDoublePoint *pt=NULL;

CBMSTSDoubleHit *hit=NULL;

for (int j=0; j < fListSTSpts->GetEntries(); j++ ) {

pt = (CBMSTSDoublePoint*) fListSTSpts->At(j);

if (pt && ( pt->GetDetectorID(0) == pt->GetDetectorID(1)) ) {

hit =AddHit(); hit->SetDetectorID( pt->GetDetectorID(1));

} else continue;

hit->SetPos_in( pt->GetPos_in() );

hit->SetPos_out( pt->GetPos_out() );

}

}

Page 17: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 17

AddHit()AddHit()

CBMSTSDoubleHit * CBMITrack::AddHit(){

// Creates a new hit in the TClonesArray.

TClonesArray& ref = *fTrackerCollection;

Int_t size = ref.GetEntriesFast();

return new(ref[size]) CBMSTSDoubleHit();

}

Page 18: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 18

Analysis Task- Init exampleAnalysis Task- Init example

void Task1::Init()

{

// Get a pointer to the ROOT Manager ( data store )

CBMRootManager *fManager =CBMRootManager::Instance();

// Get the relevant data for the Task

// activate in IO the corresponding TTree branch

fListSTSpts=(TClonesArray *)fManager->ActivateBranch("STSPoint");

// Get the data generated from a previous Task

fHitCollection=(TClonesArray *) fManager->GetRegisteredObject("STSDoubleHit");

}

Page 19: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 19

Creating the LibraryCreating the Library

• Create a directory MyTask

• In this directory create two other directories src and include

• download the Makefile from the webpage and copy it to MyTask, put the name of your package (MyTask) in the Makefile http://www-linux.gsi.de/~cbmsim/cbm_vmc_doc/Makefile_example.htm

######### Makefile #######PACKAGE =  The name of your package

• Calling Make will create a libMyTask.so in cbm_vmc/lib directory

Page 20: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 20

Analysis MacroAnalysis Macro

• Load the Libraries• Create the Run Manager • Choose input and output files• Create and add your analysis Tasks• Initialize and run the analysis

Page 21: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 21

Analysis Macro – Load librariesAnalysis Macro – Load libraries

gROOT->LoadMacro("../basiclibs.C");

basiclibs();

gSystem->Load("libCbm");

gSystem->Load ("libSTS");

gSystem->Load("libMyTask");

Page 22: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 22

Create the Run ManagerCreate the Run Manager

CBMRun *fRun= new CBMRun();

fRun->SetInputFile(“STS_AuAu25Gev_Urqmd.root");

fRun->SetOutputFile(“trackOutput.root");

Page 23: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 23

Create and add the TaskCreate and add the Task

CBMITrack *tr= new CBMITrack("Tracking Algorithm");

fRun->AddTask(tr);

Page 24: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 24

fRun->Init();

fRun->Run();

fRun->Run(10, 100);

Init and RunInit and Run

This will run over all eventsin the input file

Page 25: CBM Simulation & Analysis Framework Analysis Tasks

12.05.2004 CBM Software week 25

Analysis MacroAnalysis Macro

{gROOT->LoadMacro("../basiclibs.C"); basiclibs(); gSystem->Load("libCbm"); gSystem->Load ("libSTS"); gSystem->Load("libITrack"); CBMRun *fRun= new CBMRun(); fRun->SetInputFile(“STS_AuAu25Gev_Urqmd.root"); fRun->SetOutputFile(“trackOutput.root"); CBMITrack *tr= new CBMITrack("Tracking Algorithm"); fRun->AddTask(tr); fRun->Init(); fRun->Run();

}