Docstoc

Atlas software in Athena - PowerPoint

Document Sample
Atlas software in Athena - PowerPoint Powered By Docstoc
					 Reconstruction tutorial: Part 4
Writing a (very) simple Reconstruction/Analysis
 algorithm: Ze+e-
Simplified from a real algorithm by Maarten
 Boonekamp (thanks!)
Access egamma objects, select some, compute
 invariant mass of pairs, and save a Zee object
Check the Z in the truth




      David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
  Where you should be now
At that stage, you should have a running
 ZeeRec algorithm
  o which prints a few things (grep Zee
    AskAthena.log )
  o book variables in the ntuple but do not fill
    them
  o loop on egamma object and fill ZeeObject
    but no computation of the mass have been
    done



     David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
   Compute kinematic quantities
In method: ZeeObject::setDaughters(…) called
 by the constructor, fill two HepLorentzVector’s (
                            ) with electron 4-
    http://wwwinfo.cern.ch/asd/lhc++/clhep/doxygen/html/index.html


 momentum
m_egamma[0]=eg1; m_egamma[1]=eg2;
HepLorentzVector hlv[2];
 // get kinematics of the two electron and store in HepLorentzVector
    for ( int i=0 ; i<2 ; ++i ) {
     const LArCluster* clus = m_egamma[i]->get_Cluster();
      const double eta = (clus)->eta();
      const double phi = (clus)->phi();
      const double et = (clus)->et();
      const px = et * sin(phi);
      const py = et * cos(phi);
      const pz = et * sinh(eta);
      const en = et *cosh(eta);
       hlv[i].set(px,py,pz,en);}


               David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
         …kinematic quantities
Add 4-vectors
// sum kinematics in the internal 4-vector

m_hlvZ=hlv[0]+hlv[1];

// already coded for you in ZeeObject::mass() etc…
//     mass() : m_hlvZ.m();
//     et() : m_hlvZ.perp();
//     phi() : m_hlvZ.phi();
//     eta() : m_hlvZ.pseudoRapidity();



Run again and check the variables in the
 ntuple make sense (Z mass ?)
          David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
         Note on const policy
 We clearly want to avoid that, say, the person writing
  egamma identification modify (on purpose or by
  mistake) the content of, say, the track collection, which
  would affect downstream, say, primary vertex search
 (in some very specific case, it can be that, on purpose, a
  collection is « finished » by another algorithm. Allowed
  only if it makes the code much simpler)
 Collection in StoreGate are/will be lockedonly
  accessible through const datahandle
 The rest of the code need to be const-correct
 Note that current compiler (gcc 2.95) is not very strict
  on that, but the next one (gcc 3.2, will become the
  default in the course of the year) will be!

       David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
  Tips on const correct code
 Const double a = 1 // I promise not to modify a
 Const MyObject a = MyObject(…); // I promise never to
  modify a
 Const MyObject a* = new MyObject(…) ; //I promise
  never to modify the MyObject on which a points
 MyObject a* = new MyObject(…) const; //I promise
  never to modify a
 MyObject::MyDoer(const AnotherObject & a, const
  AnotherObject * b) ; //MyDoer promises not to modify a
  (which is passed by reference) nor the object pointed at
  by b
   o MyDoer accepts objects that are declared const or not
   o Note that the const-ness is part of the signature of the function
     so MyObject::MyDoer(const AnotherObject & a, AnotherObject *
     b) is another function

        David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
                               Tips (2)
MyObject::Doer() const; //Doer promises not to
 modify the object it belongs to
   o only such const methods can be used from an
     object that was declared const
MyObject::DoerNonConst();
const MyObject theObject;
theObject.DoerNonConst(); //will not compile (error
  message : no matching method … best match..)
theObject.Doer(); //will compile
So if you suddenly want to be const correct, all
 the code which depend on you may not compile
 any more if const-uncorrect
Hence the need to take this habit early
       David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
                               Tips (3)
Code with const is more readable because
 you immediately spot const variables
 (obviously…)
…especially when reading header files
Many mistakes can be detected at
 compile/link time through const
 correctness
A trivial example:
Const a = theObject.doer();
If (a=1) {…}; // will not compile, where is the bug ?
       David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
  Compute Z mass from tracks only
 Add variable m_massFromTracks in ZeeObject and output in the
  ntuple
 Elements of code (not complete !)
   o Add variable in ntuple (cut and paste from z_mass):
       In ZeeRec/CBNT_Zee.h add m_z_massFromTracks
       In src/CBNT_Zee.cxx : declare the ntuple variable and fill it from ZeeObj
   o Navigation from egamma object to the track:
       EMTrackMatch * trackMatch = m_egamma[i]->get_EMTrackMatch()
       SimpleTrack* track = trackMatch->getTrack();
       Do not forget to test pointers are non-null
        you will need include files SimpleTrack/SimpleTrack.h and
         egammaEvent/EMTrackMatch.h
   o Computation of kinematics
       Px=cos(track->PhiVert())/track->PTInvVert()
       Py=sin(…
       Pz=track->CotThVert()/ track->PTInvVert()
       4-momentum then mass
 Please try now…

         David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
                              HepMC
HepMC is the truth event record. It has
  vertex and particles connected in a tree.
(see http://cern.ch/hepmc )
It stores the output from the generator,
  physical particles as well as some
  history/hard scatter (GenStat=3)
Exercise: find the Z’s and its daughters in
  the truth and printout some quantities in
  the log file

     David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
Note:Geant particle in HepMC
Output from Geant3 is also stored in HepMC:
  o allow smooth navigation between generator world
    and geant world
  o Avoid duplication of particles
  o Allow same interface
  o However difficult to store geant specific information
    so this will need to be eventually improved
  o The original kine Geant3 number need to be
    recovered because it is still used to label detector
    digits
  o It is stored in barcode() or status() depending of the
    cases (see
    Generators/GenzModule/doc/GenzModule.pdf )
      David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
                       Look for the Z
//in Zeerec::execute get pointer of MC collection
 const McEventCollection* mcCollptr;
 if ( m_storeGate->retrieve(mcCollptr).isFailure() ) {
   mlog << MSG::ERROR << "Could not retrieve McEventCollection"<< endreq;
   return StatusCode::FAILURE; }
 //loop on event in event collection
 McEventCollection::const_iterator itr;
 for (itr = mcCollptr->begin(); itr!=mcCollptr->end(); ++itr) {
     const HepMC::GenEvent* myEvent=(*itr)->pGenEvt();
     HepMC::GenEvent::particle_const_iterator Part;
      //loop on particles in event
     for (Part = myEvent->particles_begin(); Part!=myEvent->particles_end(); ++Part )
     {
           // good particle
           if ((*Part)->pdg_id()==23)
           {
           //dump in log file (note that a HepMC particle is-a HepLorentzvector
      mlog << MSG::INFO << "Z found with mass " << (*Part)->momentum().m()
          << " barcode " << (*Part)->barcode() << " status " << (*Part)->status()
          << " Pt " << (*Part)->momentum().perp() << endreq ; }}}

Please try now…
     David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003
                     Find daughters
// find decay vertex
        const HepMC::GenVertex * endVert=(*Part)->end_vertex();

//loop on daughters
     for (HepMC::GenVertex::particles_out_const_iterator
         itrDau=endVert->particles_out_const_begin();
         itrDau!=endVert->particles_out_const_end(); ++itrDau )
     { mlog << MSG::INFO << " daughter found with type " << (*itrDau)-
   >pdg_id()
         << " barcode " << (*itrDau)->barcode()<< " status " << (*itrDau)-
   >status()
        << " Pt " << (*itrDau)->momentum().perp() << endreq ;
     }

Please try now…

         David Rousseau, Reconstruction Tutorial part 4, 30/31 January 2003

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:40
posted:10/13/2010
language:English
pages:13