220 likes | 425 Views
CBM Simulation Framework. M. Al-Turany, D. Bertini. ROOT based Easy to maintain (only ROOT standard services are used) The same framework can be used for simulation and/or Analysis Simulation and Analysis are completely configurable via ROOT macros
E N D
CBM Simulation Framework M. Al-Turany, D. Bertini CBM Collaboration Meeting
ROOT based Easy to maintain (only ROOT standard services are used) The same framework can be used for simulation and/or Analysis Simulation and Analysis are completely configurable via ROOT macros The G4CBM definition files for Geometry and Materials are used User analysis can be written in ROOT macros and/or Tasks Features CBM Collaboration Meeting
Design CBM Collaboration Meeting
Simulation Macro-Loading Libraries // Loading ROOT libraries gROOT->LoadMacro("../basiclibs.C"); basiclibs(); // Loading G3 Libraries or // Loading G4 Libraries gROOT->LoadMacro("../g3libs.C"); // gROOT->LoadMacro("../g4libs.C"); g3libs(); // g4libs(); gSystem->Load("libCbm"); // Loading CBM libraries CBM Collaboration Meeting
CBMRun *fRun = new CBMRun(); // Create the Run fRun->SetOutputFile("cbm.root"); //Set the output file fRun->SetMaterials("materials"); //material file name without extension ///////////////////Create and add detectors//////////////////////////////////////// CBMDetector *Cave= new CBMCaveSD("WORLD",kFALSE); Cave->SetDetId(1); fRun->AddDetector(Cave); CBMDetector *Target= new CBMTargetSD("Target",kFALSE); Target->SetGeometryFileName("PASSIVE/TARGET", "v03a"); Target->SetDetId(2); fRun->AddDetector(Target); Simulation Macro- Create Detectors CBM Collaboration Meeting
Simulation Macro- Create Detectors CBMDetector *Magnet= new CBMMagnetSD("MAGNET",kFALSE); Magnet->SetGeometryFileName("PASSIVE/MAGNET", "v03a"); Magnet->SetDetId(4); fRun->AddDetector(Magnet); CBMDetector *STS= new CBMTrackerSD("STS", kTRUE); STS->SetGeometryFileName("STS/STS", "v03a"); STS->SetDetId(6); fRun->AddDetector(STS); CBMDetector *TOF= new CBMTofSD("TOF", kTRUE); TOF->SetGeometryFileName("TOF/TOF", "v03_v10"); TOF->SetDetId(5); ListOfDetectors->Add(TOF); fRun->AddDetector(TOF); CBM Collaboration Meeting
// Urqmd Generator CBMUrqmdGenerator *fGen= new CBMUrqmdGenerator("00-03fm.100ev.f14"); // Particle Generator CBMParticleGenerator *fGen= new CBMParticleGenerator(); // Ion Generator CBMIonGenerator *fGen= new CBMIonGenerator(); // Set parameters for Ion and Particle generators fGen->SetIon(0,0,0); fGen->SetVertex(0,0,0); fGen->SetMomentum(0,0,0); fGen->SetTOF(0); fGen->SetPolarity(0,0,0); fGen->SetPDG(0); fRun->SetGenerator(fGen);// Set Generator Simulation Macro- Generator CBM Collaboration Meeting
// CBMMagField *CBMMCApplication::SetField(Int_t type, const char * FileName); // type= 0 No field // type= 1 constant field // type= 2 field map // FileName= field map file name // setting a field map// CBMMagField *fxField=fRun->SetField(2,"FIELD.v03b.map"); // setting a constant field CBMMagField *fxField=fRun->SetField(1); fxField->SetConstFieldXYZ(0, 20 ,0 ); // values are in kG // X1, Y1, Z1 , X2, Y2, Z2 fxField->SetFieldRegions(-74, -39 ,-22 , 74, 39 , 160 ); // values are in cm Simulation Macro-Magnetic Field CBM Collaboration Meeting
fRun->Init(); // Initialize the simulation Simulation: 1. Initialize the VMC (Simulation) 2. Initialize Tasks (if they are used in Simulation) fRun->Run(NoOfEvent); //Run the Simulation Simulation Macro- Run Simulation CBM Collaboration Meeting
Simulation – Output File structure TFile VMC Application • TTree • Detector Branches • Stack Branch • Run Info • Detector Info CBM Collaboration Meeting
Name Geometry file name and version Detector Id Detector Status (Active or inactive) Detector Info CBM Collaboration Meeting
Magnetic Field Field Map: file name and version Constant field: value and region Event Generator Urqmd: file name Ion Generator: parameters Particle Generator parameters Materials file name other parameters can be easily added Run Info CBM Collaboration Meeting
// Loading ROOT libraries gROOT->LoadMacro("../basiclibs.C"); basiclibs(); // Loading G3 Libraries or // Loading G4 Libraries gROOT->LoadMacro("../g3libs.C"); // gROOT->LoadMacro("../g4libs.C"); g3libs(); // g4libs(); gSystem->Load("libCbm"); // Loading CBM libraries CBMRun *fRun= new CBMRun(); // Create the Run fRun->SetInputFile("cbm.root"); CBMDeltaTask *delta= new CBMDeltaTask("Delta Electrons"); //create a task fRun->AddTask(delta); fRun->Init(); // initialize the VMC and Tasks fRun->Run(nStart, nEnd); // Run Analysis CBM Collaboration Meeting
Tasks Tree • 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) CBM Collaboration Meeting
Tasks CBM Collaboration Meeting
class CBMDeltaTask : public CBMTask { public: CBMDeltaTask(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 ~CBMDeltaTask(); ClassDef(CBMDeltaTask,1) //CBMDeltaTask } Analysis Task CBM Collaboration Meeting
void CBMDeltaTask::Init() { deltaFile= new TFile("Delta.root", "recreate"); CBMMCApplication *fcbm=CBMMCApplication::Instance(); d1 =fcbm->GetDetector("STS"); st=fcbm->GetStack(); a1= d1->GetHitList(); // clones array of hits cosg = new TH1F("Cos theta","G3 cos theta ",100, -1.,1.); mom = new TH1F("mom"," mom ",100, 0.,1.); zdis = new TH1F("zdis","G3 zdis ",100, 0.,10.); } Analysis Task- Init example CBM Collaboration Meeting
void CBMDeltaTask::Exec(Option_t * option) { CBMTrackerHit * hit=0; //STS for (int j=0; j < a1->GetEntries(); j++ ) { hit = (CBMTrackerHit*) a1->At(j); //Select target if ( hit && ( hit->GetChamberNb() == 15) ) { Int_t id = hit->GetTrackID(); if ( st->GetParticle ( id )){ nAll++; if ( st->GetParticle( id )->GetPdgCode() != 11 ) continue; .......... Analysis Task- Exec example CBM Collaboration Meeting
//Example for getting access to data CBMMCApplication *fcbm=CBMMCApplication::Instance(); //access the Application CBMDetector *d1 =fcbm->GetDetector("STS"); TClonesArray *a1= d1->GetHitList(); CBMDetector *d2 =fcbm->GetDetector("TOF"); TClonesArray *a2= d2->GetHitList(); TTree *t=fcbm->GetTree(); CBMMCStack *st=fcbm->GetStack(); Analysis Macro CBM Collaboration Meeting
CBMDetector *d1 =fcbm->GetDetector("STS"); TClonesArray *a1= d1->GetHitList(); for (int i=0; i< t->GetEntries();i++){ // loop over all events fcbm->GetEvent( i ); CBMTrackerHit * hit=0; //STS for (Int_t j=0; j < a1->GetEntries(); j++ ) { hit = (CBMTrackerHit*) a1->At(j); //Select target if ( hit && ( hit->GetChamberNb() == 15) ) { Int_t id = hit->GetTrackID(); if ( st->GetParticle ( id )){ .... Analysis Macro CBM Collaboration Meeting
if ( hit && ( hit->GetChamberNb() == 2) && (hit->GetEdep() > 0.0) ) { Int_t id = hit->GetTrackID(); TParticle *part1 = st->GetParticle ( id ); if ( part1){ if ( part1->GetPdgCode() == 11 && part1->GetFirstMother() >= 0 ) { Double_t imp = sqrt( hit->px()*hit->px() +hit->py()*hit->py()+hit->pz()*hit->pz()); if ((imp > 0.008) && (imp > 0) ) { // Momentum cut TParticle * mother =st->GetParticle (part1->GetFirstMother()); ........ } Getting History Of Particle decay CBM Collaboration Meeting
Documentation CVS repository Consolidation of the API's VMC Event Display (for both G3 and G4) Interface to handle G4CBM output files ........ Todo List CBM Collaboration Meeting