130 likes | 289 Views
CBM Simulation & Analysis Framework Connecting Data Level. M. Al-Turany, D. Bertini. CBMTask1. CBMTask2. Det 2. Det 1. output. output. input. input. filter. output. input. Data Level Structure.
E N D
CBM Simulation & Analysis FrameworkConnecting Data Level M. Al-Turany, D. Bertini CBM Software Meeting
CBMTask1 CBMTask2 Det 2 Det 1 output output input input filter output input Data Level Structure • Number of partially elaborated data levels is detector dependant, even algorithm dependant. CBMRun: TMainTask CBMTask3 • Input TTree • TClonesArray of MCPoints • Output TTree • TClonesArray of Det 1 Hits • Output TTree • TClonesArray of Det 1 Hits • TClonesArray of Det 2 Hits • Output TTree • TClonesArray of Det 1 Hits • TClonesArray of Det 2 Hits • TClonesArray of Filtered Hits CBM Software Meeting
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 Connecting Data Levels CBM Software Meeting
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 Friend TTree CBM Software Meeting
CBMTracker CBMHitProducer Det 2 Det 1 output output input input filter output input Task example CBMRun: TMainTask CBMRun: TMainTask CBMTRD TRDHits Urqmd STSMCPts Urqmd CBMRun: TMainTask STSHits STSMCPts CBM Software Meeting
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(); STSDoubleHit producer macro CBM Software Meeting
CBMFilter Det 1 output input Task example with friend input Input: STSMCPts Friend:STSHits Output Friend: TRDHit CBM Software Meeting
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(); } Filter Task Example CBM Software Meeting
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 entries for (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 Task::Exec() example CBM Software Meeting
// Load basic libraries gROOT->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 back TFile *f=new TFile("../run/STSD_AuAu25GeV_Urqmd_100evt.root"); TFile *f1=new TFile(“STSDoubleHit.root"); TFile *f2=new TFile(“STSTRDHit.root"); //Get the TTree TTree *t1 = (TTree*) f->Get("cbmsim"); t1->AddFriend("cbmsim",f1); t1->AddFriend("cbmsim",f2); Analysis Macro with ROOT (1) CBM Software Meeting
/Get the Folders TFolder *fd1 = f->Get("cbmroot"); TFolder *fd2 = f1->Get("cbmout"); // link the different structures to the input tree TClonesArray *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; Analysis macro with ROOT (2) CBM Software Meeting
// 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 … Analysis Macro with CBM_VMC CBM Software Meeting
// 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(); Analysis Macro with CBM_VMC CBM Software Meeting