Exercise 7

  1. Example code
    1. ex07.fcl # art -c Ex07/ex07.fcl # root -l ../art-workbook/artwb/Ex07/ex07.cint
  2. Suggested Activities
    1. Two ways to look at source code:
    1. less $ART_WORKBOOK_BASE_INC/artwb/MCDataProducts/GenParticleCollection.h # less $ART_WORKBOOK_BASE_INC/artwb/MCDataProducts/GenParticle.h # Or via online code browser: GenParticleCollection.h and GenParticle.h # CLHEP a Class Library for HEP. "Home page": # For CLHEP, find files at
    1. $CLHEP_INC/CLHEP/Vector/ThreeVector.h, $CLHEP_INC/CLHEP/Vector/ThreeVector.icc # $CLHEP_INC/CLHEP/Vector/LorentzVector.h, $CLHEP_INC/CLHEP/Vector/LorentzVector.icc # Weird conventions: file names do not match clsas names. # Explain .icc convention; we do not recommend it (CLHEP is old). # OR code browser: Hep3Vector.h
      HepLorentzVector # Look at the printout and understand it.
    1. The ordinal number ( index in the collection ) # Particle Data Group (pdg) id code of the particle ( see ex08 ). 333 is a Phi, /- 321 are K and K-. # Position at creation ( always (0,0,0) ). # 4 Momentum at creation. # Status code ( 0=particle was not decayed in the generator; 1= particle was decayed in generator). Meaning will be clear later. # Indexing information for parent and for children. If not present then the word "none" appears. # In the parent printout, for example "1:2 0". The 1:2 is a data product ID ( defined later - basically it says that parent is in the same GenParticleCollection as the child ) and the 0 is the index into the GenParticleCollection. So both particles 1 and 2 have a parent of 0,while 0 has no parent. # In the child printout the same info is present but is formatted differently ( ooops ); the index is separated from the product Id by a dot (.) rather than whitespace. # Both HepLorentzVector and Hep3Vector have a member function named mag. They do different things. On a Hep3Vector it returns the magnitude of the momentum. On a HepLorentzVector it returns the invariant mass. This does make sense in that it mimics that standard mathematical notation; but it is a common mistake to use the mag function expected to get a momentum and instead getting a mass. # Run ex07Activity01.fcl
    1. This breaks up a long one-liner in into smaller steps. This might make it easier to understand. The const& are very important or else you make needless and wasteful copies. # Also add a few new histograms to illustrate properties of CLHEP::Hep3Vector and CLHEP::HepLorentzVector # Needed to add the header <cmath> to get the constant M_PI. # root -l ../art-workbook/artwb/Ex07/ex07Activity01.cint # art -c Ex07/ex07Activity02.fcl
    1. Many different ways to write the same loop as was in We recommend the version in but you will see the others.
  3. Ideas
    1. Looping in many different ways # Attributes of a GenParticle # CLHEP # CLHEP::Hep3Vector # CLHEP::HepLorentzVector # <cmath>