1 / 42

CBM Simulation & Analysis Framework Simulation Part

CBM Simulation & Analysis Framework Simulation Part. M. Al-Turany, D. Bertini. Software distribution Adding Modules and Detectors What to implement ? Creating the library Creating the simulation Macro The output file structure. Outline. The CBM software is distributed via anonymous CVS

elmo
Télécharger la présentation

CBM Simulation & Analysis Framework Simulation Part

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CBM Simulation & Analysis FrameworkSimulation Part M. Al-Turany, D. Bertini CBM Software week- M. Al-Turany

  2. Software distribution Adding Modules and Detectors What to implement ? Creating the library Creating the simulation Macro The output file structure Outline CBM Software week- M. Al-Turany

  3. The CBM software is distributed via anonymous CVS CVS login cvs -d :pserver:anonymous@www-linux.gsi.de:/misc/cbmsim/CVS/cbmrepos  login     password:   Please type nothing just press enter CVS Checkout cvs -d :pserver:anonymous@www-linux.gsi.de:/misc/cbmsim/CVS/cbmrepos  checkout cbm_vmc CVS Update cvs -d :pserver:anonymous@www-linux.gsi.de:/misc/cbmsim/CVS/cbmrepos  update Software distribution CBM Software week- M. Al-Turany

  4. make: in the cbm_vmc directory will build everything in sub-directory will build only the corresponding library make analysis This will build only the Geant3 part of the software for the simulation and the analysis part which is independent of the MC engine. After a CVS update it is recommoneded to use make clean first and then make. Building the software CBM Software week- M. Al-Turany

  5. 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 Run Manager Module Mixed Generator Detector Tasks List STS Magnetic Field Delta IO Manager TRD Tracking TOF digitizers Field Map RICH CBM Software week- M. Al-Turany

  6. Material definitions Geometry definitions Create a detector (or Module) class Create the library Create a ROOT macro Run the Simulation macro What is needed to add a detector or a Module ? CBM Software week- M. Al-Turany

  7. carbondioxide COMPONENTS 1.9768e-3 2 elC 0.27 elO 0.73 #fi TRDgas COMPONENTS 5.4476e-3 2 elXe 0.85 carbondioxide 0.15 Material Definition Material name Composition Density Single element Fractional mass Mixture of Composite CBM Software week- M. Al-Turany

  8. AlPlate1S3R 0 world -162.912 0 986.742 0.986643 0 0.162895 0 1 0 -0.162895 0 0.986643 aluminium BOX 40.8947 440.536 0.1 #fi Geometry definition Volume name Sensitivity flag (0,1) Mother volume Transformations Material Shape name Shape parameters CBM Software week- M. Al-Turany

  9. #ifndef MABGNET_H #define MABGNET_H #include "CBMModule.h" class CBMMagnet : public CBMModule { public: CBMMagnet(const char * name, const char *Title="CBM Magnet"); CBMMagnet(); virtual ~CBMMagnet(); ClassDef(CBMMagnet,1) //CBMMagnet }; #endif //MABGNET_H Creating a Module class – definition CBM Software week- M. Al-Turany

  10. #include "CBMMagnet.h" CBMMagnet::CBMMagnet(const char * name, const char *Title) :CBMModule(name ,Title) { } CBMMagnet::~CBMMagnet(){} CBMMagnet::CBMMagnet(){} ClassImp(CBMMagnet) Creating a Module class – Implementation CBM Software week- M. Al-Turany

  11. Class Definition for MyDet Class #ifndef MYDET_H #define MYDET_H #include "CBMDetector.h" class CBMVolume; class CBMMyDet : public CBMDetector { CBMMyDet(); CBMMyDet(const char * name, Bool_t Active); virtual ~CBMMyDet(); Creating a detector class – definition (1) CBM Software week- M. Al-Turany

  12. virtual ConstructGeometry(); virtual void Initialize(); virtual void Register(); virtual Bool_t ProcessHits(CBMVolume *v=0); virtual void EndOfEvent(); virtual void Print() const; virtual void Reset(); ClassDef(CBMMyDet,1) //CBMMyDet private: TClonesArray *MyDetPoint; }; // #endif //RICH_H Creating a detector class – definition (2) CBM Software week- M. Al-Turany

  13. CBMTracker::CBMTracker(const char * name, Bool_t Active) : CBMDetector(name,Active), { fTrackerCollection = new TClonesArray("CBMSTSPoint"); } Detector Constructor CBM Software week- M. Al-Turany

  14. If the CBM standard ASCII format for detector or module description is used, you do not need to implements this function If you use another format or need additional information to be added, then you have to overwrite this function, e.g. TRD and RICH ConstructGeometry() CBM Software week- M. Al-Turany

  15. void CBMCave::ConstructGeometry() { TGeoMCGeometry *vmcGeo=(TGeoMCGeometry *) TGeoMCGeometry::Instance(); if(vmcGeo==0) vmcGeo = new TGeoMCGeometry("CBM Geometry", "cbm"); world[0] = 2000; world[1] = 2000; world[2] = 2000; TString Name="air"; TGeoMedium * air = 0; Int_t nair = 0 ; if ( (air = gGeoManager->GetMedium(Name.Data())) ) nair = air->GetId(); TString name("world"); Int_t VolId= vmcGeo->Gsvolu(name.Data(), "BOX", nair , world, 3); CBMVolume *aVol=new CBMVolume(name,0,1); CBMDetector::vList->addVolume( aVol ); TGeoVolume *vol=gGeoManager->GetVolume(VolId); gGeoManager->SetTopVolume(vol); } ConstructGeometry() - Example 1 CBM Software week- M. Al-Turany

  16. void CBMRich::ConstructGeometry() { CBMModule::ConstructGeometry(); // optical properties TGeoMedium * richGas = gGeoManager->GetMedium("RICHgas") ; const Int_t NUMENTRIES = 2; Double_t ppckov[NUMENTRIES] = { 4.1E-10, 2.07E-9 }; //rich gas Double_t rindexGas[NUMENTRIES] = { 1.000298, 1.000298 }; //N2 Double_t absorptionGas[NUMENTRIES] = { 1.0e+03, 1.0e+03 }; Double_t efficiencyGas[NUMENTRIES] = {1.,1.}; gMC->SetCerenkov (richGas->GetId(),NUMENTRIES,ppckov, absorptionGas,efficiencyGas,rindexGas); } ConstructGeometry() - Example 2 CBM Software week- M. Al-Turany

  17. If you do not need any special initialization of your detector, then do not implement this method. Otherwise use: MyDet::Initialize() { CBMDetector::Initialize() // Has to be called .....Your Code } Initialize() CBM Software week- M. Al-Turany

  18. This method is called internally from the initialized function void CBMTracker::Register() { // Registers the hits collection in Root manager. //This will create a branch STSPoint in the output tree CBMRootManager::Instance()->Register("STSPoint","STS", fTrackerCollection); } Register() CBM Software week- M. Al-Turany

  19. This method is called usually from the ProcessHit() to add a new object to the container (TClonesArray) CBMSTSPoint* CBMTracker::AddHit() { // Creates a new hit in the TClonesArray. TClonesArray& ref = *fTrackerCollection; Int_t size = ref.GetEntriesFast(); return new(ref[size]) CBMSTSPoint(); } AddHit() CBM Software week- M. Al-Turany

  20. This Method is call from the Stepping in each event Bool_t CBMTracker::ProcessHits(CBMVolume *v) { // Creates hits (in stepping). Double_t edep = gMC->Edep(); if (edep==0.0) return kFALSE; // cut on energy if (gMC->Etot() < 0.05 ) return kFALSE; CBMSTSPoint* mcPoint = AddHit(); mcPoint->SetTrackID (gMC->GetStack()->GetCurrentTrackNumber()); // Chamber no mcPoint->SetDetectorID(v->getMCid()); ProcessHits(CBMVolume *v) (1) CBM Software week- M. Al-Turany

  21. mcPoint->SetELoss (edep); // Energy deposit mcPoint->SetEtot(gMC->Etot()); // total Energy mcPoint->SetTime( gMC->TrackTime()); mcPoint->SetLength(gMC->TrackLength() ); TLorentzVector pos; // Position gMC->TrackPosition(pos); mcPoint->SetPos (TVector3(pos.X(), pos.Y(), pos.Z())); TLorentzVector mom; // Momentum gMC->TrackMomentum(mom); mcPoint->SetMom (TVector3(mom.X(), mom.Y(), mom.Z())); return kTRUE; } ProcessHits(CBMVolume *v) (2) CBM Software week- M. Al-Turany

  22. Bool_t CBMRich::ProcessHits(CBMVolume *v) { TParticle *part = gMC->GetStack()->GetCurrentTrack(); Int_t gcode = part->GetPdgCode(); if (gcode == 50000050) { //check if a Cerenkov photon ............................. return kTRUE; }else{ return kFALSE; } } ProcessHits(CBMVolume *v) CBM Software week- M. Al-Turany

  23. This method is called at the end of processing an event void CBMTracker::EndOfEvent() { // Prints hits collection (if verbose) if (fVerboseLevel>0) Print(); Reset(); } EndOfEvent() CBM Software week- M. Al-Turany

  24. This method is called after processing an event void CBMTracker::Reset() { // Reset hits collection fTrackerCollection->Clear(); } Reset() CBM Software week- M. Al-Turany

  25. These Methods can be overloaded in your detector: virtual void BeginEvent(); virtual void BeginPrimary(); virtual void PreTrack(); virtual void PostTrack(); virtual void FinishPrimary(); Additional Methods in the CBMDetector CBM Software week- M. Al-Turany

  26. Create a directory MyDet In this directory create two other directories src and include download the Makefile from the webpage and copy it to MyDet, put the name of your package (MyDet) in the Makefile http://www-linux.gsi.de/~cbmsim/cbm_vmc_doc/Makefile_example.htm ######### geant4vmc Makefile #######PACKAGE =  The name of your package Calling Make will create a libMyDet.so in cbm_vmc/lib directory Creating the Library CBM Software week- M. Al-Turany

  27. Load the Libraries Create the Run Manager Choose Simulation engine Choose an output file name Create Modules and detectors and add them to the Run Manager Create and Set the Event generator(s) Create and set the Magnetic field Initialize and run the simulation Simulation Macro CBM Software week- M. Al-Turany

  28. Simulation Macro – loading Libs // Load basic ROOT libraries gROOT->LoadMacro("../basiclibs.C"); basiclibs(); // Load CBM modular libraries gSystem->Load("libCbm"); gSystem->Load("libPassive"); gSystem->Load("libGen"); gSystem->Load("libSTS"); gSystem->Load("libTrd"); gSystem->Load("libTof"); gSystem->Load("libRich"); gSystem->Load("libITrack"); CBM Software week- M. Al-Turany

  29. //create the Run Manager Class CBMRun *fRun = new CBMRun(); // set the MC version used fRun->SetName("TGeant4"); //for G3 use "TGeant3" // chose an output file name fRun->SetOutputFile("test.root"); Simulation Macro CBM Software week- M. Al-Turany

  30. CBMModule *Cave= new CBMCave("WORLD"); fRun->AddModule(Cave); CBMModule *Target= new CBMTarget("Target"); Target->SetGeometryFileName("PASSIVE/TARGET", "v03a"); fRun->AddModule(Target); CBMModule *Pipe= new CBMPIPE("PIPE"); Pipe->SetGeometryFileName("PASSIVE/PIPE", "v03a"); fRun->AddModule(Pipe); CBMModule *Magnet= new CBMMagnet("MAGNET"); Magnet->SetGeometryFileName("PASSIVE/MAGNET", "v03a"); fRun->AddModule(Magnet); Simulation Macro- Create Modules CBM Software week- M. Al-Turany

  31. CBMDetector *STS= new CBMTracker("STS", kTRUE); STS->SetGeometryFileName("STS/STS", "v03c"); fRun->AddModule(STS); CBMDetector *TOF= new CBMTof("TOF", kTRUE ); TOF->SetGeometryFileName("TOF/TOF", "v03_v10"); fRun->AddModule(TOF); CBMDetector *TRD= new CBMTRD("TRD",kFALSE ); TRD->SetGeometryFileName("TRD/TRD", "v04b_9" ); fRun->AddModule(TRD); Simulation Macro- Create Detectors CBM Software week- M. Al-Turany

  32. CBMUrqmdGenerator *fGen1= new CBMUrqmdGenerator("00-03fm.100ev.f14"); CBMPlutoGenerator *fGen2= new CBMPlutoGenerator("jpsi.root"); CBMParticleGenerator *fGen3= new CBMParticleGenerator(); // use: SetVertex, SetMomentum, ... etc , to set the parameters of this Generator //name, z, a , q , e(GeV), m CBMNewIon *fIon= new CBMNewIon("My_Au", 79, 197, 79, 25.,183.47324); fRun>AddNewIon(fIon); CBMIonGenerator *fGen4= new CBMIonGenerator(fIon); // use: SetVertex, SetMomentum, ... etc , to set the parameters of this Generator CBMAsciiGenerator fGen5= new CBMAsciiGenerator(filename.txt); Simulation Macro-Event Generators CBM Software week- M. Al-Turany

  33. CBMMixedGen *fGen= new CBMMixedGen("Mix"); fGen->AddGenerator(fGen1); fGen->AddGenerator(fGen2); fGen->AddGenerator(fGen3); fGen->AddGenerator(fGen4); fGen->AddGenerator(fGen5); fRun->SetGenerator(fGen); Event Generators-Mixing generators CBM Software week- M. Al-Turany

  34. // setting a field map CBMFieldMap *fMagField= new CBMFieldMap("FIELD.v03b.map"); // setting a constant field CBMConstField *fMagField=new CBMConstField(); fMagField->SetFieldXYZ(0, 10 ,0 ); // values are in kG // MinX=-74, MinY=-39,MinZ=-22 ,MaxX=74, MaxY=39 ,MaxZ=160 ); fMagField->SetFieldRegions(-74, -39 ,-22 , 74, 39 , 160 ); // values are in cm fRun->SetField(fMagField); Simulation Macro-Magnetic Field CBM Software week- M. Al-Turany

  35. 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 Software week- M. Al-Turany

  36. 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 Reading Output files CBM Software week- M. Al-Turany

  37. Output File CBMMCApplication Geometry Folder Structure Output Tree CBM Software week- M. Al-Turany

  38. 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(); The CBM VMC Application CBM Software week- M. Al-Turany

  39. 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 The CBM VMC Application CBM Software week- M. Al-Turany

  40. 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] The Magnetic Field CBM Software week- M. Al-Turany

  41. The Output Tree Detector Braches Stack CBM Software week- M. Al-Turany

  42. 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"); Reading from the Tree CBM Software week- M. Al-Turany

More Related