FedraVMC Tutorial
From AstroNuWiki
Revision as of 16:17, 11 January 2014 by AstroNuAdmin (Talk | contribs)
Tutorial macros
Following tutorial macros can be found in macro/tutorials/ directory of current version
tutorial1.C
Illustration of basic simulation: simulate and draw
EMCApplication *appl = NULL; if (!TVirtualMCApplication::Instance()) appl=new EMCApplication("tutorial1", "FVMC tutorial #1"); else appl = (EMCApplication*)TVirtualMCApplication::Instance(); appl->SetGeneratorName("PromptTracks"); ///propagation of primary particles with given attributes ///you may use different transports: // appl->InitMC("g3Config.C"); ///use GEANT3 // appl->InitMC("flConfig.C"); ///use FLUKA appl->InitMC("g4Config.C"); ///use GEANT4 ///set primary parameters: appl->GetGenerator()->SetNumberOfPrimaries(10); //10 primaries at once! appl->GetGenerator()->SetPDG(211); //set pdg code of primary: pi+ appl->GetGenerator()->SetEnergyInterval(2,5); //set energy of primary - random from 2 to 5 Gev appl->GetGenerator()->SetThetaInterval(0,45); //initial inclination angle. From 0 to 45 degrees appl->GetGenerator()->SetPosInterval(TVector3(-1,-1,-3.6),TVector3(1,1,-3.6)); //initial position - in cm appl->RunMC(1,true); ///simulate 1 event and close simulation VMCEvent* event=appl->GetEventTree(); ///get simulated event gGeoManager->GetTopVolume()-> Draw(); ///draw brick event->DrawTracks("CN"); /// draw both charged and neutral tracks
You should get a canvas with something like this:
tutorial2.C
Illustration of simulation and reconstruction
/// ///tutorial macro - illustration of event simulation and reconstruction ///Author: Andrey Sheshukov // simulation part - same as in tutorial1 EMCApplication *appl = NULL; if (!TVirtualMCApplication::Instance()) appl=new EMCApplication("tutorial1", "FVMC tutorial #1"); else appl = (EMCApplication*)TVirtualMCApplication::Instance(); appl->SetGeneratorName("PromptTracks"); ///propagation of primary particles with given attributes ///you may use different transports: //appl->InitMC("g3Config.C"); ///use GEANT3 //appl->InitMC("flConfig.C"); ///use FLUKA appl->InitMC("g4Config.C"); ///use GEANT4 ///set primary parameters: appl->GetGenerator()->SetNumberOfPrimaries(5); //5 primaries at once! appl->GetGenerator()->SetPDG(15); //set pdg code of primary: tau- appl->GetGenerator()->SetEnergyInterval(2,5); //set energy of primary - random from 2 to 5 Gev appl->GetGenerator()->SetThetaInterval(0,45); //initial inclination angle. From 0 to 45 degrees appl->GetGenerator()->SetPosInterval(TVector3(-1,-1,-3.6),TVector3(1,1,-3.6)); //initial position - in cm appl->RunMC(1,true); ///simulate 1 event and close simulation VMCEvent* event=appl->GetEventTree(); //get simulated event TCanvas *c1=new TCanvas("tutorial2","Simulation&Reconstriction",800,300); c1->Divide(2,1); c1->cd(1); gGeoManager->GetTopVolume()-> Draw(); //draw brick event->DrawTracks("C"); // draw only charged tracks //gPad->GetView3D()->SetParallel(); //prepare reconstruction GenRec* GR=new GenRec(); ///create interface to FEDRA GR->InitRec(); ///initialize reconstruction GR->SetEvt(event); ///get an event GR->GetV2C()->SetScanVol(-3e4,3e4,-3e4,3e4,0,0); ///set scanning volume (6x6cm x all z range) ///if you want full brick use (0,0,0,0,0,0) //do reconstruction GR->V2C(); ///transform segments to FEDRA format GR->Prepare(); ///link FEDRA segments //GR->Align(); /// do the alignment based on current tracks GR->RecTracks(); ///reconstruct the tracks GR->RecVertex(); ///reconstruct vertices //draw reconstruction c1->cd(2); GR->DrawBrick();///draw brick volume GR->DrawSV(); ///draw scanning volume GR->DrawHits(); ///draw FEDRA segments GR->DrawTracks(1.); ///draw rec tracks GR->DrawVertices(2.); ///draw rec vertices(displayed as stars) - may not be found in some particular cases! ///clean reconstruction - use following lines in case you wan to clear reconstructed tracks&vertices ///(for example in case you want to use reconstruction in cycle): //GR->ResetTracks(); //GR->ResetVertex(); //GR->ResetAlign(); ///If you want to clear all FEDRA segments in GR use this: //GR->Clear(); //close reconstruction GR->CloseRec(); c1->cd(1)->GetView()->SetParallel();
You should get a canvas with something like this: