Top Banner
Material and Detector Implementation in FairSHIP Annarita Buonaura Università di Napoli & INFN 7th SHiP Collaboration Meeting, CERN, February 10 - 12, 2016
31

Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Oct 12, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

MaterialandDetectorImplementationinFairSHIPAnnaritaBuonauraUniversità diNapoli&INFN

7thSHiPCollaborationMeeting,CERN,February10- 12,2016

Page 2: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

OUTLINE

AnnaritaBu

onaura-FairS

hipTutoria

l

2

Ø IntroductionØ Creatinganewdetectorclass

Ø TheCMakeLists fileØ TheDetectorClass

Ø DescribingadetectorØ CreatingtheshapeØ CreatingthemediumØ Creatingandpositioning thevolumeØ ProcessHits() ,GetCollection()andAddHit() methods

Ø TheHitsclassØ Howtomakeeverythingwork

Ø TheLinkDef.h fileØ ParameterfileØ MakeFairShipknowaboutyourdetector

Ø Summary

Page 3: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Introduction• SHiP geometryenvironmentismainlybasedontheROOT/TGEOpackage.

• Itisatoolforbuilding,browsing,navigatingandvisualizingdetectorgeometries

• ParticletransportisobtainedbyworkingincorrelationwithsimulationpackagessuchasGEANT3,GEANT4andFLUKA

• Tocreateanewdetectoryouhavetoimplementsomeclasseswhichwilldescribeyourdetector.

• Todescribeadetector(possiblyinanewfolderofFairShip/)itisimportanttoimplement:• theCMakeFile• thedetectorclass• thedetectorMCPointclass

AnnaritaBu

onaura-FairS

hipTutoria

l

3

Page 4: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

CREATINGANEWDETECTORCLASS

AnnaritaBu

onaura-FairS

hipTutoria

l

4

Page 5: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

TheCMakeLists File

AnnaritaBu

onaura-FairS

hipTutoria

l

5

• Forastandalonedetectorcreateanewfolder.• Whencreatinganewfolder(e.g:FairShip/Box)itisnecessarytofirstdefinea

CMakeLists filecontainingthenamesofthe.cxxfileinthefolder.• Itwillcreatealibrarywhichincludes thesourcefileswritteninthefolder .

Page 6: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

TheDetectorClass

AnnaritaBu

onaura-FairS

hipTutoria

l

6

• Twofilesmustbecreated:a.hfileanda.cxxusuallywiththesamename

• The.hfile(headerfile)containsdeclarationof:• private/protectedmemberoftheclass(NB:donotdefine

themhere)• functions(methods)

• The.cxxfilecontains:• implementationofthemethodsdeclaredinthe.hfile

Page 7: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

7

Describingadetector

• Anewdetectorclasscaninheritfromtwodifferentabstractbaseclasses:• FairModule:

• DefinesageometryelementwhichdoesnotproduceMCpoints(passivedetectorssuchas/FairSHip/passive/ShipMuonShield.cxx)

• FairDetector:• Definesageometryelementwithactivevolumes(e.g.adetector)

• ItisasubclassoftheFairModule onewhichimplementsextrafunctionscalledfromtheeventloopoftheMCtomakesomeactionsduringsimulations

Page 8: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Createadetectorvolume

AnnaritaBu

onaura-FairS

hipTutoria

l

8

TGeoVolume *top=gGeoManager→GetTopVolume();

• Todefineavolumeitisnecessarytocreatemedia andshapes.• Bothcontainersandcontainedvolumesmustbecreatedbefore

linkingthemtogether:arelativetransformationmatrixmustalsobeprovided.

• Anyvolumehastobepositionedsomewhereotherwiseitwillnotbeconsideredaspartofthegeometry.

• Thebasicbricksforbuilding-upthemodelarecalledvolumes.• Volumesareputoneinsideanothermakinganin-depthhierarchy.The

onecontainingallothersdefinesthe “world” ofthemodel.• InFairShiptheworldhasalreadybeendefinedanditcanbecalled

using:

Page 9: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

9

Createadetectorshape• Eachvolumehasashape.• Itprovidesthedefinitionofthelocalcoordinate

systemofthevolume.• Anyshapehastoderivefromthebase

TGeoShape class.• 20basic(primitive)shapesarealreadyprovided:

• Boxes:TGeoBBoxclass• Parallelepipid:TGeoParaclass• Trapezoids:TGeoTrd1class• Cones– TGeoConeClass• Arbitrary8verticesshapes- TGeoArb8class• Tubes– TGeoTubeClass…

• CompositeshapescanalsobecreatedasaresultofBooleanoperationsbetweenprimitives

Page 10: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

10

Createadetectorshape(2)• Allprimitiveshaveconstructorslike:

TGeoXXX(const char*name,<type>param1,<type>param2,…);TGeoXXX(<type> param1,<type>param2,…);

• Example:

TGeoBBox(Double_t fX,Double_t fY,Double_t fZ,Double_t *origin=0);

HalflengthinXHalflengthinYHalflengthinZOriginofthebox:(0,0,0)bydefault

NB:Thedefaultlengthunitsarecentimetres

xz

ypbeam

Page 11: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

11

Definingthemedia• Togetherwithshapes,volumesneedmediatobecreated,because

materialsrepresentthephysicalpropertiesofthesolid fromwhichavolume ismade.

• TheTGeoMedium class defines themedia,thatarematerialwithtrackingparametersneededforthetransport(sensitivity flag, fieldflag,maxfieldvalue....)

• Newmediacanbeaddedtothegeometry/media.geo.file• Therecanbemultiplekindofdefinitions accordingtotheknowledgeofthe

differentpropertiesof theconsideredmedium

Page 12: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

12

Definingthemedia(2)

Page 13: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

13

Createadetectorvolume(2)• Basicstrategy

Step1:Definethegeometry

Step2:Definethemedia

Step3:Definethevolume

TGeoBBox *fBox =newTGeoBBox(Double_t fX,Double_t fY,Double_t fZ);

InitMedium("iron");TGeoMedium *Fe=gGeoManager->GetMedium(“iron");

TGeoVolume *fBoxVol =newTGeoVolume("volBox",fBox,Fe);

Page 14: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Positioningthevolume

AnnaritaBu

onaura-FairS

hipTutoria

l

14

• Beforepositioningavolume,itsmothervolumemustbecreated

• Daughtervolumesmustnotextrudetheirmothershape.

• Positionsofdaughtervolumeswithrespecttothecenterofmothervolumemustbeknown:ageometricaltransformationwhenpositioningdaughtervolumesmustbeprovided.

• Volumesinthesamecontainermustnotoverlapwitheachother

• Ifthedetectorconsistsofarepetitionofunitarycells(e.g.10ironlayers):• Notcreateadifferentshapeandadifferentvolumeforeachcell• Itisenoughtoreplicatetheonesthathavebeenalreadycreated

Page 15: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Positioningthevolume(2)

AnnaritaBu

onaura-FairS

hipTutoria

l

15

Example:Boxpositionedintopvolume

TGeoVolume*top=gGeoManager→GetTopVolume();

TGeoBBox*fBox =newTGeoBBox(Double_t fX,Double_t fY,Double_t fZ);InitMedium("iron");TGeoMedium*Fe=gGeoManager->GetMedium(“iron");TGeoVolume*fBoxVol =newTGeoVolume("volBox",fBox,Fe);TGeoTranslation *fT =newTGeoTranslation(fTx,fTy, fTz);top ->AddNode(fBoxVol,1,fT);

TGeoBBox*fScint =newTGeoBBox (Double_t fX,Double_t fY,Double_t fScintZ);InitMedium(“scint”);TGeoMedium*Fe=gGeoManager->GetMedium(“Scintillator");TGeoVolume*fScintVol =newTGeoVolume("volScint",fScint,scint);for(Int_t n=0;n<nReplica;n++){

TGeoTranslation *t=new TGeoTranslation(0,0,-fZ+n*(fScintZ+0.1)]fScint/2);fBox ->AddNode(VBox,n,t);

}

Calltopvolume

DefineBox

DefineBoxmaterial

DefineBoxvolume

Position oftheboxw.r.t.topvolumePosition theboxintopvolume

Numberofreplica

TGeoTranslationNumberofreplica

Translationsalongx,y,z w.r.t.centerofmothervolume

Mothervolume

Page 16: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

ProcessHits()

AnnaritaBu

onaura-FairS

hipTutoria

l

16

Page 17: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

ProcessHits()

AnnaritaBu

onaura-FairS

hipTutoria

l

17

GetstheIDofthevolumewherethehitwasreleased

Checks ifthereareoverlappingvolumes

GetsthepdgCode associatedtotheTparticle object

Evaluatesmeanpositionofhitsinthesensitivevolume

Addinghitstosave

Page 18: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Savingthehits:GetCollection()&AddHit()

AnnaritaBu

onaura-FairS

hipTutoria

l

18

Page 19: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Thehitsclass

AnnaritaBu

onaura-FairS

hipTutoria

l

19

• Usuallycreatedwithaname***Point• ItinheritsfromtheFairMCPoint class

• Asforthedetectorclass:

• .hfile:• Pointconstructorwith/without arguments

• trackID =IndexofMCtrack• detID =DetectorID• pos =Coordinates atthecenteroftheactivevolume [cm]• mom =Momentumoftrackatentrance[GeV]• tof =Timesinceeventstart[ns]• length=Tracklengthsincecreation[cm]• eLoss =Energydeposit [GeV]• pdgcode=Pdg Codeofthetrack

• Definitionoffunctionsactingontheclass• Example:Int_t PdgCode()const {return fPdgCode;}

• .cxxfile:• …offuctionsdefined in.hfile

Page 20: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

HOWTOMAKEEVERYTHINGWORK…

AnnaritaBu

onaura-FairS

hipTutoria

l

20

Page 21: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

ParameterFile

AnnaritaBu

onaura-FairS

hipTutoria

l

21

• Inorder tostudydifferentdetectordesigns,basicgeometryparametersshouldbegivenbyinstantiationofthegeometryobjects,nothardcoded inC++class.

• Basicparametersareingeometry/geometry_config.py

Examplec.Box =AttrDict(z=0*u.cm)c.Box.BX =3*u.m;c.Box.BY =3*u.m;c.Box.BZ =3*u.m;

• Geometryobjectsarecreatedbypython/shipDet_conf.py anddeclaredtotherunmanagerFairRunSim()

ExampleBox=ROOT.Box("Box",ship_geo.Box.BX,ship_geo.Box.BY,ship_geo.Box.BZ,ROOT.kTRUE)run.AddModule(Box)

Page 22: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

TheLinkDef.h file

AnnaritaBu

onaura-FairS

hipTutoria

l

22

• Inthefolderofyourdetector.• TheROOTCINTprogramgeneratestheStreamer(),TBuffer &operator>>() and

ShowMembers() methods forROOTclassesaswellastheCINTdictionariesneeded inorder togetaccesstoonesclassesviatheinterpreter

• TheLinkDef filetellsROOTCINTforwhichclassesthemethod interfacestubsshouldbegenerated.

Page 23: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

MakeFairSHIPknowaboutyourdetector

AnnaritaBu

onaura-FairS

hipTutoria

l

23

• FairShip/CMakeLists.txt• TomaketheFairShipsoftwarereadthenewfolder, itisimportant toinsertthe

titleof thefolderamongthosecontainedinthegeneralCMakeLists.txt file

• shipdata/ShipDetectorList.h• IntheconstructoroftheBoxclassaunique identifier isgiventothedetector

thathastobeadded tothelistoftheotheridentifiers :

Page 24: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Summarizing

AnnaritaBu

onaura-FairS

hipTutoria

l

24

• Tocreateanewdetectorfolder:• Addyourfolder intheFairShipdirectory• Modify theFairShip/CMakeLists.txt adding thenameofyourfolderafterendif

(no fairrootfound) withcommandadd_subdirectory (foldername)• InShipdata/ShipDetectorList.h addtheunique identifieryougivetoyour

detector(thesameyouwillneedtouseinoneoftheconstructorofyourdetectorclass.

• Inthenewfolder:• CreateaCMakeLists.txt fileanda***LinkDef.h file• Ifdetectorisactivecreatethe***Point.h (.cxx) files(otherwiseskip)• Createthedetectorclass(YourDetector.h(.cxx))andifthedetectorispassivedo

notusefunctions readhits(seeforexampleFairShip/passive/ShipMagnet.h)• Checkifthemediaofwhichyourdetectorismadeisalreadybeencreatedin

geometry/media.geo (otherwisecreateusing infoon theslides)• Add theparametersofyourdetectorinthegeometry/geometry_config.py file• Createthegeometryobjectcorresponding toyourdetectorbydefining itin

python/shipDet_conf.py

Page 25: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

Summarizing

AnnaritaBu

onaura-FairS

hipTutoria

l

25

• Thisisjustaveryshortintroduction onthepossibilitiesgivenbyFairROOT tocreatenewdetectorgeometries.

• Thebestwaytolearnistotry,tryandtry,alsobytakingalookatwhatotherpeoplehavedone.

• Forfurther information onthegeometrypackagepleaserefertotheFairROOTdocumentation

Page 26: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

AnnaritaBu

onaura-FairS

hipTutoria

l

26

Page 27: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

BACK– UPSLIDES

AnnaritaBu

onaura-FairS

hipTutoria

l

27

Page 28: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

InitMediumFunction

AnnaritaBu

onaura-FairS

hipTutoria

l

28

InFairShip mediaareread bythegeometry/media.geo filethroughout theprivatefunction InitMedium:

Int_t XXX::InitMedium(const char*name){static FairGeoLoader *geoLoad=FairGeoLoader::Instance();static FairGeoInterface *geoFace=geoLoad->getGeoInterface();static FairGeoMedia *media=geoFace->getMedia();static FairGeoBuilder *geoBuild=geoLoad->getGeoBuilder();FairGeoMedium *ShipMedium=media->getMedium(name);if (!ShipMedium){Fatal("InitMedium","Material %s not defined inmediafile.",name);return -1111;}

TGeoMedium*medium=gGeoManager->GetMedium(name);if (medium!=NULL)return ShipMedium->getMediumIndex();

return geoBuild->createMedium(ShipMedium);}

Page 29: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

MagneticField

AnnaritaBu

onaura-FairS

hipTutoria

l

29

• Thevalueofthemagneticfieldcanbedefinedasaprivatememberofthedetectorclass.

Note:ThisisvalidonlyinFairShip.NecessarytomanipulateG4geometrytoenablemagneticfieldinactiveshielding.

Privatefixinrun_simScript.py tomakeitwork#manipulateG4geometrytoenablemagneticfieldinactiveshielding, VMCcan'tdoit.importgeomGeant4geomGeant4.setMagnetField()#('dump')forprintoutofmagfields

Example:

TGeoUniformMagField *magField =newTGeoUniformMagField(0.,-MagneticField,0.);fBoxVol->SetField(magField);

Page 30: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

TheHitsclass(example)

AnnaritaBu

onaura-FairS

hipTutoria

l

30

Page 31: Material and Detector Implementation in FairSHIP€¦ · Material and Detector Implementation in FairSHIP Annarita Buonaura Universitàdi Napoli & INFN 7th SHiP Collaboration Meeting,

TheDetectorClass(2)

AnnaritaBu

onaura-FairS

hipTutoria

l

31