C++ / G4MICE Course
description
Transcript of C++ / G4MICE Course
C++ / G4MICE Course
Session 7
Models vs RepresentationsPersistency
Real Data FormatsReader
Models vs Representations• So far we have been making models of various
experiments using the MiceModule class.• When we run the simulation, event display,
reconstruction, etc, some information from the model is required.
• This information needs to be supplied in a manner appropriate to the use of the model (e.g. GEANT4 vs RecPack)
• To solve the potential problem of having the modelling code depend on every potential use that it could be put to, we make the distinction between models and representations.
2
If We Only had a Model
3
Model
GEANT4
RecPackHepRep
ROOT
Reconstruction
SimulationEvent Display
With Representations
4
Model
GEANT4
Simulation
Simulation Representation
RecPack
Reconstruction
Reconstruction Representation
G4MICE Representations
• Simulation:– DetModel and EngModel– Take the MiceModule model and create the
necessary G4 objects
• Reconstruction:– SetupKalman (Recon/SciFi)
• Event Display:– Visualization– Uses HepRep XML writer.
5
“The Data”
• When using G4MICE or writing use applications, we don’t think about the data files or the data formats.
• The data exists in instances of various classes (e.g. SciFiHit, VlpcHit, etc...)
• So when you want to find “some data” what you really need to do is work out what class(es) represent that data and what method(s) can provide it.
6
Persistency
• The classes that represent the data only exist in the computer’s memory while the program is running – they are transient.
• We want to store the classes in some format so that they can “live” beyond the execution of the program – make them persistent.
• This can involve writing them to disk, to a database, ...
7
Gzipped Text File• The current persistency method that is
implemented is a gzipped text file.• The Zlib library is used to perform zipping and
unzipping as the files are written or read.• The format is plain text so can be read for
debugging purposes.• You should never write your own code to read
this (or any other format) file unless you are specifically involved in the development of the persistency code.
8
Persistency Design
9
Transient Class(e.g. SciFiHit)
Gzipped Text File
SciFiHitTextFileIo
MySQL
SciFiHitMySQL
Real Data Formats• We currently have code that reads a
number of other specific file formats associated with different DAQs that have been used in MICE to date:– KEK test beam (2 different formats)– Tracker test with Visual Basic (2 different
formats)
• Work is in progress to implement the code to read in the DATE format files and produce the relevant classes.
10
Reader• All of the classes that read the various file formats
(whether persistent text file, or test beam or other DAQ formats) are derived from a purely virtual base class called Reader.
• It requires all the derived classes to implement a few methods:– readEvent()– isOK()– closeInputFile()– skipEvents()
11
Code Inspection• Have a look at:
– Interface/include/Reader.hh– Persist/textFile/include/TextFileReader.hh– RealData/include/VlsbReadout2006.hh
• See how each of the classes implements a version of (a kind of!) the Reader class.
• See how this is used in:– Applications/common/GlobalReader.hh– Applications/KekOct2005/Kek2005.cc– Applications/KekOct2005/cards.in
12
Remaining Time this Session
• Continue work on the MuScat modelling and simulation assignment...
13