AIDASoft / DD4hep

Detector Description Toolkit for High Energy Physics
http://dd4hep.cern.ch
GNU Lesser General Public License v3.0
53 stars 100 forks source link

How to make DD4hep output quiet? #279

Closed whit2333 closed 6 years ago

whit2333 commented 6 years ago

Hi Everyone,

I am developing some command line tools around dd4hep and when loading a compact file dd4hep outputs a lot of text. Is there an easy way to silence this output with a verbosity level or something else?

Cheers

PS I am talking about this kind of output:

PersistencyIO    INFO  +++ Set Streamer to dd4hep::OpaqueDataBlock                                                                                                                                                 
PersistencyIO    INFO  +++ Patching TGeoVolume.fUserExtension to persistent                                                                                                                                        
PersistencyIO    INFO  +++ Patching TGeoNode.fUserExtension to persistent                                
Info in <TGeoManager::TGeoManager>: Geometry world, Detector Geometry created                            
DocumentHandler  INFO  +++ Loading document URI: sieic.xml [Resolved:'sieic.xml']                        
DocumentHandler  INFO  +++ Document sieic.xml succesfully parsed with TinyXML .....                                                                                                                                
DocumentHandler  INFO  +++ Loading document URI: ./elements.xml [Resolved:'./elements.xml']                                                                                                                        
DocumentHandler  INFO  +++ Document ./elements.xml succesfully parsed with TinyXML .....                                                                                                                           
DocumentHandler  INFO  +++ Loading document URI: ./materials.xml [Resolved:'./materials.xml']            
DocumentHandler  INFO  +++ Document ./materials.xml succesfully parsed with TinyXML .....                
Detector         INFO   *********** created World volume with size :    3000    3000    3000             
Info in <TGeoManager::SetTopVolume>: Top volume is world_volume. Master volume is world_volume           
Info in <TGeoNavigator::BuildCache>: --- Maximum geometry depth set to 100                                                                                                                                         
Compact          INFO  ++ Converted subdetector:SiVertexBarrel of type SiEIC_SiTrackerBarrel [tracker]    
petricm commented 6 years ago

You can use setPrintLevel

petricm commented 6 years ago

What kind of command line tools are you working on? There is a set of command line tools developed in iLCSoft/lcgeo called ddsim which already offer the following functionality and is also independent of the rest of iLCSoft.

2017-12-11 17:46 mpetric@pclcd24:CLICSiD$ ddsim --help
optional arguments:
  -h, --help            show this help message and exit
  --steeringFile STEERINGFILE, -S STEERINGFILE
                        Steering file to change default behaviour
  --compactFile COMPACTFILE
                        The compact XML file
  --runType {batch,vis,run,shell}
                        The type of action to do in this invocation
                        batch: just simulate some events, needs numberOfEvents, and input file or gun
                        vis: enable visualisation, run the macroFile if it is set
                        run: run the macroFile and exit
                        shell: enable interactive session
  --inputFiles INPUTFILES [INPUTFILES ...], -I INPUTFILES [INPUTFILES ...]
                        InputFiles for simulation .stdhep, .slcio, .HEPEvt, .hepevt, .hepmc, .pairs files are supported
  --outputFile OUTPUTFILE, -O OUTPUTFILE
                        Outputfile from the simulation,only lcio output is supported
  -v {1,2,3,4,5,6,7,VERBOSE,DEBUG,INFO,WARNING,ERROR,FATAL,ALWAYS}, --printLevel {1,2,3,4,5,6,7,VERBOSE,DEBUG,INFO,WARNING,ERROR,FATAL,ALWAYS}
                        Verbosity use integers from 1(most) to 7(least) verbose
                        or strings: VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS
  --numberOfEvents NUMBEROFEVENTS, -N NUMBEROFEVENTS
                        number of events to simulate, used in batch mode
  --skipNEvents SKIPNEVENTS
                        Skip first N events when reading a file
  --physicsList PHYSICSLIST
                        Physics list to use in simulation
  --crossingAngleBoost CROSSINGANGLEBOOST
                        Lorentz boost for the crossing angle, in radian!
  --vertexSigma X Y Z T
                        FourVector of the Sigma for the Smearing of the Vertex position: x y z t
  --vertexOffset X Y Z T
                        FourVector of translation for the Smearing of the Vertex position: x y z t
  --macroFile MACROFILE, -M MACROFILE
                        Macro file to execute for runType 'run' or 'vis'
  --enableGun, -G       enable the DDG4 particle gun
  --enableG4GPS         enable the Geant4 GeneralParticleSource. Needs a macroFile (runType run) or use it with the shell (runType shell)
  --enableG4Gun         enable the Geant4 particle gun. Needs a macroFile (runType run) or use it with the shell (runType shell)
  --dumpParameter, --dump
                        Print all configuration Parameters and exit
  --enableDetailedShowerMode
                        use detailed shower mode
  --dumpSteeringFile    print an example steering file to stdout
  --filter.mapDetFilter FILTER.MAPDETFILTER
                         a map between patterns and filter objects, using patterns to attach filters to sensitive detector 
  --filter.tracker FILTER.TRACKER
                         default filter for tracking sensitive detectors; this is applied if no other filter is used for a tracker
  --filter.filters FILTER.FILTERS
                         list of filter objects: map between name and parameter dictionary 
  --filter.calo FILTER.CALO
                         default filter for calorimeter sensitive detectors; this is applied if no other filter is used for a calorimeter 
  --field.delta_intersection FIELD.DELTA_INTERSECTION
  --field.min_chord_step FIELD.MIN_CHORD_STEP
  --field.equation FIELD.EQUATION
  --field.stepper FIELD.STEPPER
  --field.largest_step FIELD.LARGEST_STEP
  --field.delta_chord FIELD.DELTA_CHORD
  --field.eps_min FIELD.EPS_MIN
  --field.eps_max FIELD.EPS_MAX
  --field.delta_one_step FIELD.DELTA_ONE_STEP
  --guineapig._parameters GUINEAPIG._PARAMETERS
  --guineapig.particlesPerEvent GUINEAPIG.PARTICLESPEREVENT
                        Set the number of pair particles to simulate per event.
                            Only used if inputFile ends with ".pairs"
                            If "-1" all particles will be simulated in a single event

  --gun.thetaMin GUN.THETAMIN
  --gun.phiMin GUN.PHIMIN
                        Minimal azimuthal angle for random distribution
  --gun.direction GUN.DIRECTION
                         direction of the particle gun, 3 vector 
  --gun.particle GUN.PARTICLE
  --gun.multiplicity GUN.MULTIPLICITY
  --gun.energy GUN.ENERGY
  --gun.thetaMax GUN.THETAMAX
  --gun.isotrop GUN.ISOTROP
                         isotropic distribution for the particle gun

                            use the options phiMin, phiMax, thetaMin, and thetaMax to limit the range of randomly distributed directions
                            if one of these options is not None the random distribution will be set to True and cannot be turned off!

  --gun.position GUN.POSITION
                         position of the particle gun, 3 vector 
  --gun.distribution {uniform,cos(theta),eta,pseudorapidity,ffbar}
                        choose the distribution of the random direction for theta

                            Options for random distributions:

                            'uniform' is the default distribution, flat in theta
                            'cos(theta)' is flat in cos(theta)
                            'eta', or 'pseudorapidity' is flat in pseudorapity
                            'ffbar' is distributed according to 1+cos^2(theta)

                            Setting a distribution will set isotrop = True

  --gun.phiMax GUN.PHIMAX
  --random.type RANDOM.TYPE
  --random.enableEventSeed
                        If True, calculate random seed for each event based on eventID and runID
                        allows reproducibility even when SkippingEvents
  --random.replace_gRandom RANDOM.REPLACE_GRANDOM
  --random.luxury RANDOM.LUXURY
  --random.file RANDOM.FILE
  --random.seed RANDOM.SEED
  --part.minDistToParentVertex PART.MINDISTTOPARENTVERTEX
                        Minimal distance between particle vertex and endpoint of parent after
                            which the vertexIsNotEndpointOfParent flag is set

  --part.enableDetailedHitsAndParticleInfo
                        Enable lots of printout on simulated hits and MC-truth information
  --part.keepAllParticles PART.KEEPALLPARTICLES
                         Keep all created particles 
  --part.minimalKineticEnergy PART.MINIMALKINETICENERGY
                        MinimalKineticEnergy to store particles created in the tracking region
  --part.saveProcesses PART.SAVEPROCESSES
                        List of processes to save, on command line give as whitespace separated string in quotation marks
  --part.printStartTracking PART.PRINTSTARTTRACKING
                         Printout at Start of Tracking 
  --part.printEndTracking PART.PRINTENDTRACKING
                         Printout at End of Tracking 
  --action.tracker ACTION.TRACKER
                         set the default tracker action 
  --action.mapActions ACTION.MAPACTIONS
                         create a map of patterns and actions to be applied to sensitive detectors
                                example: SIM.action.mapActions['tpc'] = "TPCSDAction" 
  --action.calo ACTION.CALO
                         set the default calorimeter action 
  --output.random {1,2,3,4,5,6,7,VERBOSE,DEBUG,INFO,WARNING,ERROR,FATAL,ALWAYS}
                        Output level for Random Number Generator setup
  --output.kernel {1,2,3,4,5,6,7,VERBOSE,DEBUG,INFO,WARNING,ERROR,FATAL,ALWAYS}
                        Output level for Geant4 kernel
  --output.part {1,2,3,4,5,6,7,VERBOSE,DEBUG,INFO,WARNING,ERROR,FATAL,ALWAYS}
                        Output level for ParticleHandler
  --output.inputStage {1,2,3,4,5,6,7,VERBOSE,DEBUG,INFO,WARNING,ERROR,FATAL,ALWAYS}
                        Output level for input sources
  --physics.rangecut PHYSICS.RANGECUT
                         The global geant4 rangecut for secondary production

                            Default is 0.7 mm as is the case in geant4 10

                            To disable this plugin and be absolutely sure to use the Geant4 default range cut use "None"

                            Set printlevel to DEBUG to see a printout of all range cuts,
                            but this only works if range cut is not "None"

  --physics.pdgfile PHYSICS.PDGFILE
                         location of particle.tbl file containing extra particles and their lifetime information

  --physics.decays PHYSICS.DECAYS
  --physics.list PHYSICS.LIST
  --lcio._parameters LCIO._PARAMETERS
  --lcio.mcParticleCollectionName LCIO.MCPARTICLECOLLECTIONNAME
                        Set the name of the collection containing the MCParticle input.
                            Default is "MCParticle".
MarkusFrankATcernch commented 6 years ago

Typically setting the print level should be fine. Example:

$> geoDisplay -compact <file-name> -print WARNING

should suppress nearly all output, which is INFO. The python interface in DDG4 also allows you to manipulate this level.

whit2333 commented 6 years ago

Hi @petricm and @petricm,

Thanks for the quick feedback!

dd4hep::setPrintLevel(dd4hep::WARNING) worked perfectly. It is in the header DD4hep/Printout.h. This in combination with gErrorIgnoreLevel = kWarning; got most everything suppressed.

I am working on some simple command line tool that extract targeted geometries. One tool does the TEve geometry extraction/magic required for TEveProjections. Similarly, another tool is used for targeted TGeo to STEP conversion of specific geometries.

I am aware of lcgeo's ddsim. Indeed it has all the bells and whistles :).

Cheers