CBM Simulation & Analysis Framework Connecting Data Level
description
Transcript of CBM Simulation & Analysis Framework Connecting Data Level
10.05.2004 CBM Software Meeting 1
CBM Simulation & Analysis FrameworkCBM Simulation & Analysis FrameworkConnecting Data LevelConnecting Data Level
M. Al-Turany, D. Bertini
10.05.2004 CBM Software Meeting 2
Data Level StructureData Level Structure
CBMTask2
input
outputDet 2
CBMTask1
input
outputDet 1
CBMTask3
input
outputfilter
CBMRun: TMainTask
Input TTree • TClonesArray
of MCPoints
Output TTree • TClonesArray
of Det 1 Hits
Output TTree • TClonesArray
of Det 1 Hits
• TClonesArray of Det 2 Hits
• TClonesArray of Filtered Hits
Output TTree • TClonesArray
of Det 1 Hits
• TClonesArray of Det 2 Hits
• Number of partially elaborated data levels is detector dependant, even algorithm dependant.
10.05.2004 CBM Software Meeting 3
Connecting Data LevelsConnecting Data Levels
• Every Analysis tasks produces detector/algorithm dependant Data Levels
• Problem: we don’t want to copy always all Data Levels in one BIG TTree– Not optimized ( IO, mass storage)– Not suitable in code development period– May be OK for DST production, etc…
• Solution:– CBM_VMC support usage of friend TTree Mechanism– Can be seen as a ntuple merging mechanism
10.05.2004 CBM Software Meeting 4
Friend TTreeFriend TTree
• Dynamic addition of TTree Structure on Top of an existing TTree
• Allow to connect different Data Levels without limitation on internal structure in the friend trees.
• Friend mechanism is an internal feature of the TTree class
10.05.2004 CBM Software Meeting 5
Task exampleTask example
CBMHitProducer
input
outputDet 2
CBMTracker
input
outputDet 1
CBMTRD
input
outputfilter
CBMRun: TMainTask
CBMRun: TMainTask
CBMRun: TMainTask
Urqmd STSMCPts
STSHits
STSMCPts
Urqmd TRDHits
10.05.2004 CBM Software Meeting 6
STSDoubleHit producer macroSTSDoubleHit producer macro
gROOT->LoadMacro("../basiclibs.C"); basiclibs(); CBMRun *fRun= new CBMRun(); fRun->SetName("TGeant3"); fRun->SetInputFile("Urqmd_100evt.root");fRun->LoadGeometry(); fRun->SetOutputFile("cbmout.root");
CBMSTSDoubleHitProducer *tr= new CBMSTSDoubleHitProducer("DHit conversion");
//Smear the MCPoint in X and Y Double_t dx = 10. e-4; // 10 mu in X Double_t dy = 10. e-4; // 10 mu in Y tr->SmearingXY(dx , dy ); fRun->AddTask(tr); fRun->Init();fRun->Run();
10.05.2004 CBM Software Meeting 7
Task example with friend input Task example with friend input
CBMFilter
input
outputDet 1
Friend: TRDHit
Input: STSMCPts
Friend:STSHits
Output
10.05.2004 CBM Software Meeting 8
Filter Task Example Filter Task Example
• CBMFilter::Init() get pointer to Data level structure from differents input files
void CBMFilter::Init() {
CBMRootManager *fManger =CBMRootManager::Instance();
cl1=(TClonesArray *) fManger->ActivateBranch("STSDoublePoint");
cl2=(TClonesArray *) fManger->ActivateBranch("STSDoubleHit");
cl3=(TClonesArray *) fManger->ActivateBranch("TRDHit");
// test validity for pointers cl1,cl2, cl3…
Register();
}
10.05.2004 CBM Software Meeting 9
Task::Exec() exampleTask::Exec() example
void CBMSTSDoubleHitProducer::Exec(Option_t * option) { If (cl1)cout << "CBMSTSDoubleHitProducer::Exec : MCPts entries " << cl1->GetEntriesFast() <<endl; If (cl2) cout << "CBMSTSDoubleHitProducer::Exec : STS Hit entries " << cl2->GetEntriesFast() <<endl;If (cl3)cout << "CBMSTSDoubleHitProducer::Exec : TRD entries " << cl3->GetEntriesFast() <<endl;
CBMSTSDoublePoint *stsPts=NULL; CBMSTSDoubleHit *stshit=NULL; CBMTRDHit *trdhit=NULL;// loop over STSDoublePoints entriesfor (int j=0; j < cl1->GetEntries(); j++ ) {// .. do something with STSDoublePoints for (int k=0; k < cl2->GetEntries(); k++ ) { //… do something with STSHit for (int k=0; k < cl2->GetEntries(); k++ ) { // … do something with TRDHit
10.05.2004 CBM Software Meeting 10
Analysis Macro with ROOT (1)Analysis Macro with ROOT (1)
// Load basic librariesgROOT->LoadMacro("../basiclibs.C");basiclibs();
// … here load other necessary libraries// Load analysis libraries gSystem->Load("libCbm"); gSystem->Load("libSTS"); gSystem->Load("libTrd");// Use friend mechanism to read all stuff backTFile *f=new TFile("../run/STSD_AuAu25GeV_Urqmd_100evt.root"); TFile *f1=new TFile(“STSDoubleHit.root");TFile *f2=new TFile(“STSTRDHit.root");//Get the TTreeTTree *t1 = (TTree*) f->Get("cbmsim");
t1->AddFriend("cbmsim",f1); t1->AddFriend("cbmsim",f2);
10.05.2004 CBM Software Meeting 11
Analysis macro with ROOT (2)Analysis macro with ROOT (2)/Get the FoldersTFolder *fd1 = f->Get("cbmroot"); TFolder *fd2 = f1->Get("cbmout");
// link the different structures to the input treeTClonesArray *stsPoint = (TClonesArray*) fd1->FindObjectAny("STSDoublePoint"); TClonesArray *stsHit = (TClonesArray*) fd2->FindObjectAny("STSDoubleHit"); t1->SetBranchAddress(stsPoint->GetName(),&stsPoint);t1->SetBranchAddress(stsHit->GetName(),&stsHit);
for(Int_t i=0;i<t1->GetEntries();i++ ) { t1->GetEntry(i); // loop over Double hit for (Int_t j=0;j<stsHit->GetEntriesFast();j++){ CBMSTSDoubleHit * hit = (CBMSTSDoubleHit*) stsHit->At(j); // find now the corresponding MCpoint to this hit CBMSTSDoublePoint * pt = (CBMSTSDoublePoint*) stsPoint->At(hit->GetRefIndex()); // print the Z value of hit to the outer boundary // and the corresponding TOF at that point cout << "DHit Zout:" << hit->z_out() << endl; cout << " corresponding Tof " << pt->GetTime(1) << endl;
10.05.2004 CBM Software Meeting 12
Analysis Macro with CBM_VMCAnalysis Macro with CBM_VMC
// Load basic lib gROOT->LoadMacro("../basiclibs.C"); basiclibs();// Load Libraries gSystem->Load("libCbm"); gSystem->Load("libSTS"); gSystem->Load("libTrd");// Create a new Run CBMRun *fRun= new CBMRun();
fRun->SetInputFile("../run/STSD_AuAu25GeV_Urqmd_100evt.root"); // Adding friend trees TFile *f= new TFile("cbmstshit.root"); TFile *f1= new TFile("../trd/cbmtrdhit.root"); fRun->AddFriend(f); fRun->AddFriend(f1);
fRun->SetOutputFile("cbmtotal.root"); … now add your tasks …
10.05.2004 CBM Software Meeting 13
Analysis Macro with CBM_VMCAnalysis Macro with CBM_VMC
// create the taks and add it to the RUN
CBMFilter *tr= new
CBMFilter(“STS-TRDHit selection");
// Smear the MCPoint in X and Y
Double_t dx = 10. e-4; // 10 mu in X
Double_t dy = 10. e-4; // 10 mu in Y
tr->SmearingXY(dx , dy );
fRun->AddTask(tr);
fRun->Init();
fRun->Run();